[Solved] Using the fire bullet behavior, but it's acting a bit funny. Help please

When I use it for the first time, it will be placed one pixel below the intended position, and then subsequent ones will be in the correct position, which is the center of the ship object. If I keep firing, it will be correct, however, if let all of them leave the screen, then I shoot again and again it’s down one line.

Here is the event:

Here is a screenshot of the problem:

Second screenshot showing the correct position:

Not really sure why. Checked the numbers and they seem to read the same, so I don’t know, a problem with the fire a bullet behavior?

Please let me know if I can fix this?

Quick Edit: After further inspection, it seems to be a problem with Bullet.Height() – not sure why, but I’ve narrowed it down to that. I tried logging it to the console, but it’s reporting the proper height of 10, but I use ToString(Bullet.Height()) and it correctly reports the height, so I don’t know if there’s some floating point problem there or not. To sum up Bullet.Height() seems to be the culprit.

I’m wondering if there’s some almost random rounding going on with the calculations.

Anyway, instead of calculating the position, add a point (say called BulletStart) to the space ship at the nose, where you want the bullet to originate. The set the origin of the bullet to be midway the height. When you fire, place the bullet at the at pointX("BulletStart), pointY(“BulletStart”)

The first time you fire a bullet, the bullet object has never existed before. Therefore the bullet.height() doesn’t exist (and is 0).

You could probably fix this by adjusting the origin point to be centered on the Y axis, then add a custom point on the ship “firing point”, and have the bullet fire from that point’s position instead.

1 Like

Okay will try that, thanks!

Edit: Well added a point, and that seems to work fine. So thanks guys.