Bullet positions getting set to NaN

0 favourites
  • 4 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Hey all, I have some objects in my game with the bullet behavior that I'm doing a lot of stuff to (disabling and enabling bullet, bouncing off of certain objects, adjusting positions and angles, pinning, unpinning, changing speeds and accelerations, etc.)

    I'm running into an issue where every now and then a bullet object's position will be set to NaN by something (both x and y values). I haven't been able to repro it reliably, but I do notice it often happens when a bullet decelerates to 0. When it gets to the point where I expect it to stop, it will vanish, and checking the debugger reveals that the object still exists but has NaN as the position.

    The project is kind of large and sprawling so I can't easily link it, but was just wondering if anyone has run into this issue or had suggestions for debugging to try and figure out why the position is getting set to NaN, or if there's a way the bullet behavior can end up dividing by 0 or whatever.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are probably doing a calculation that results in NaN. 0 is a common case where things go wrong: divide anything by 0 and you'll get infinity or NaN, and then passing that result to other calculations can result in more NaNs.

  • What would be the most likely input culprits for divide-by-0 calculation with the bullet behavior? Speed? Acceleration? Position? Angle?

  • I have narrowed it down to the Bounce event. If I manually bounce something off an object while it is decelerating, when the speed reaches 0 it will sometimes get NaN as its position (but not always).

    Ashley - I'll continue to try and isolate the issue and see if I can get a repro-able .capx, but does anything jump to mind knowing this?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)