Help with equation for movement overshooting

Just started using Construct 2? Post your questions here

Post » Tue Jan 27, 2015 8:29 am

Screenshot (4).png

So, I've got a line of code highlighted that's causing a problem for me. It works, about 98% of the time. But its a pretty core piece of functionality. What I'm doing is moving my character from point to point on the screen, with spikes that cause death on either side. The code is supposed to adjust its location to the waypoint's Y over the time it takes for the waypoint to cross the Y. About 1 out of 50 times though it overshoots. I'm assuming there's a better way to do this than what I managed to mash out, so help?

The character only moves on the Y axis, and the waypoints have a fixed Y but move on the X axis.
You do not have the required permissions to view the files attached to this post.
Posts: 16
Reputation: 284

Post » Wed Jan 28, 2015 2:44 am

It's a little hard to understand what's happening just based on the code and your description. In any case it's NOT a complete view. Looks like your using some variables but, it's not clear what they represent. Can you post a capx?
Posts: 673
Reputation: 9,338

Post » Sun Feb 01, 2015 8:41 am

Turns out I was a little hasty. Basically I was rolling my own movement code when I could have just used the Physics behavior. That simplified things and fixed my bug.

Basically what you're looking at in the photo is the highlighted line. It takes the X and Y of the Waypoint and calculates how much to move the character by based on how far the waypoint is away. So if the waypoint is 5 units away from the character's X and 5 units away from the character's Y, the character moves so that the x difference will be 0 when the y difference is 0. See this video: "" Thanks though!
Posts: 16
Reputation: 284

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests