Eresor's Recent Forum Activity

  • Yeah, that's what we were telling you from the beginning. That's why I suggest checking variable values using Browser Log, you would've seen the issue straight away.

    Yeah, that was on me. Didn't think there would be multiple ones at the same time.

    Still, thank you for your help

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry, try this one:

    (Overheat / 6) * (max(WeaponLevel,100) - 100) ^(1.5 * ((max(WeaponLevel,100) - 100) / 10) /2)

    That seems to have done the trick!

    Thank you all very much!

    I think I also found the source of the glitch.

    So I have this object that stores the WeaponLevel on all weapons. Now the issue is that I had them on all three layouts, which resulted in three of them being active on a layout at once (because they were global and also had the behavior "Persist". Going into the debug mode, I saw that one of them had the default variables (every level on 0) which was probably the issue.

  • Try this:

    (Overheat / 6) * (max(WeaponLevel,100) - 100) ^(1.5 * ((max(WeaponLevel,100) - 100) / 10) /2) ,1, 100)

    .

    If it fixes the problem, it will mean that sometimes WeaponLevel can be <100

    The formula doesn't work. It has too many paranthesis or something, idk.

    And I know for a fact that the WeaponLevel is not less than 100. Otherwise I would not be able to use the weapon.

  • You can use clamp() or max() as suggested earlier in the thread to make sure x can never be a negative number, or you can change your formula to not use a fractional exponent.

    When using clamp the bullets still come out as NaN every now and then as I mentioned earlier.

    The clamp formula that was suggested earlier was different than mine, and I want to use this formula (or something that ends up with the same results).

    When I tried with clamp I did the formula:

    clamp((Overheat / 6) * (WeaponLevel - 100) ^(1.5 * ((WeaponLevel - 100) / 10) /2) ,1, 100)

    As I mentioned, still came out as NaN every now and then.

    Am I doing this wrong?

  • x^1.5 = x^(3/2) = sqrt(x^3)

    A negative number raised to the third power will result in a negative number, and the square root of a negative number will result in NaN.

    So what do you reccomend I do?

    The weird thing is that the damage NaN thing only happens for this weapon, while for the others there haven't been any problems

  • Edit: (-10)^1.5 returns NaN, so the most likely reason is that WeaponLevel is less than 100 for some bullets. A simple fix would be adding max(WeaponLevel,100)

    I checked for this aswell. That is not the case. As long as the weapon is unlocked, it is at atleast 100. For the testing I'm doing, the WeaponLevel value is at 106.

    I will try out the browser log part aswell.

    However, I do believe it has something to do with the Overheat value, due to it constantly changing, and due to the NaN value coming out at random times

  • clamp((Overheat / 6) * (WeaponLevel - 100),0,YourMaxValue)

    I've never really understood how clamps work. I tried this out, and at some points the damage would come out as 0, which I'm guessing would normally be the NaN? However, this formula you provided is also different than the one I normally use.

    I tried putting it on my own formula, which turned into:

    clamp((Overheat / 6) * (WeaponLevel - 100) ^(1.5 * ((WeaponLevel - 100) / 10) /2) ,1, 100)

    When I used that, the values still came out as NaN every now and then.

  • One of your variables is probably a string and not a number, which is what NaN stands for.

    I checked the variables used in the formula, and all of them seem to be numbers, not strings.

    Any other ideas?

  • So I've been working on this weapon upgrade system for my game, and it has worked perfectly until it came across my minigun weapon.

    The special thing with the minigun is that it can overheat, and when overheating (but not fully overheated) it will do more damage.

    The formula for bullet damage for other weapons with the upgrading is as follows:

    BulletDamage * (WeaponLevel - 100) ^(1.5 * ((WeaponLevel - 100) / 10) /2)

    The "weaponlevel" is always at atleast 100 when usable, and can increase up to 110.

    For the overheated minigun bullets, the previous formula was "Overheat / 6". The overheat would never go above 100, and never shoot overheated bullets when below 40.

    The new formula for the overheated bullets is:

    (Overheat / 6) * (WeaponLevel - 100) ^(1.5 * ((WeaponLevel - 100) / 10) /2)

    However, in a few bullets, the damage comes out as "NaN" and when it hits an enemy, the HP of the enemy also becomes "NaN" and it becomes immortal.

    Why is this, and how do I fix it?

  • Alright, that worked! Thank you and everyone else who helped me with this!

  • It depends on how do you do the scrolling.

    I scroll using the ScrollTo behavior on the playable character.

  • Enable "unbounded scrolling", which gives you an effectively unlimited layout area. Then you can impose your own custom scrolling boundaries that can change in events.

    The unbounded scrolling effect seems quite handy for this situation. I'm just a bit confused on how I can set scrolling boundaries. Any ideas?

Eresor's avatar

Eresor

Member since 4 Aug, 2020

None one is following Eresor yet!

Trophy Case

  • 4-Year Club
  • Email Verified

Progress

5/44
How to earn trophies