Advertisement

Moving ship towards mouse click not working well in the “boundary deadzone”?

Started by October 06, 2016 09:09 AM
1 comment, last by Andor Patho 8 years, 5 months ago

http://pastebin.com/JM1ckbKt

The problem is that clicking on a new target position or dragging the mouse while the spaceship is in motion will cause the ship to follow the cursor, but I am trying to do 1 click, spaceship flies there and cannot redirect before it reaches the target. I tried to achieve this by not letting it change the target position with the flag (!m_moving) while flying and I tested this by debugging it and it seems the target is not changing which is great which is why im confused as to why it lets me do this. I've disabled repeated key presses for the windows.

The second problem is the boundaries, sometimes it works correctly but often it won't, the spaceship will fly through at times. I've printed out targetposition vs the distancetotravel, and it showed it working for a while and then eventually (the targetposition starts increasing when it should be gradually decreasing before it satisfies the condition that targetposition

http://imgur.com/a/L4RTE

^ This shows the targetdistance > distancetotravel when it goes towards the boundary, as you can see it bugs out at one point, and I can't think why because it works fine if its not against the boundary.

Could you establish the context in English instead of C++?
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
Advertisement

The problem is that clicking on a new target position or dragging the mouse while the spaceship is in motion will cause the ship to follow the cursor

When is your Shooter::update method called? Is it called automatically e.g. every frame? If so, that is what's causing the problem. The movement of your ship is always in the m_angle direction, regardless of the target position, and m_angle gets updated to point toward the mouse position via Shooter::angleShipToMouse everytime update is called.

This topic is closed to new replies.

Advertisement