Jump to content
  • Advertisement
Sign in to follow this  
Giancarlo Gatti

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

This topic is 652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!