Top down movement

For questions about using Classic.

Post » Tue Aug 10, 2010 7:37 pm

Hi all. I've been working on a little test to get a multi layered character to move around. The torso faces the mouse and the legs are supposed to move logically in relation to it. Problem I've hit all of a sudden (this is very messy and unfinished, be warned) is that the 'mouselook' that orientates the torso seems to just stop if the pointer is static. It works for a few seconds while you move around then after that, it only reorientates if you move the mouse. Something I've missed?

Any help would be appreciated. Also any suggestions on where to improve or make this more efficient would be massively appreciated.

Try leaving the mouse alone in one spot then using WASD to walk round it and eventually it stops rotating.

[url:18bprbkq]http://www.mediafire.com/?67qonmzz3p0ascc[/url:18bprbkq]

Cheers :)
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Tue Aug 10, 2010 9:07 pm

It seems to be a bug in anglediff - if the torso and the arrow ever have the same angle (I.E. the arrow, the torso, and the mouse are on the same line) the difference between them becomes 0 and gets stuck there.

As near as I can tell, your aim with those calculations is to make the player's torso turn to face the mouse more quickly at the beginning of its turn and then ease into place, right?
B
2
S
1
G
2
Posts: 35
Reputation: 870

Post » Tue Aug 10, 2010 9:44 pm

That's correct yeah, the torso never jumps directly to face the mouse pointer but smoothly rotates and then decelerates as it approaches the target angle :)
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Wed Aug 11, 2010 12:22 am

Here's a cap demonstrating a much cleaner and easier way to smoothly rotate a sprite towards the cursor.

[url:3ozt06db]http://dl.dropbox.com/u/9498285/smoothangle.cap[/url:3ozt06db]
B
2
S
1
G
2
Posts: 35
Reputation: 870

Post » Wed Aug 11, 2010 1:34 am

That's awesome! Much neater and more efficient, and it's solved my problem too :)

Thanks for the help! Any other suggestions or improvements would be great :)

Now to try and get my diagonal movement working :S Haha
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Thu Aug 12, 2010 12:37 pm

I've applied this method to a basic kindof space ship type movements alike asteroids. I'm just wondering if there's a fix for this.

If you set the speed of turning to be relatively slow, the turn takes longer to face the pointer, obviously. Due to the speed at which you can move the mouse, it's possible to 'overtake' the 180 point and therefore shorten the turning distance. What this does is it creates a little jerk as it switches from rotating clockwise to anti-clockwise, or vice versa.

I'm wondering if there's a simple/efficient way to keep it rotating in the same direction once it's picked up momentum, as this little switch looks unnatural and it's really niggling me :P
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Fri Aug 13, 2010 3:05 pm

Any ideas on this? It's frustrating me to the point of making me feel sick :( Every example online just doesn't apply! I'm trying to get it to decelerate before it begins the rotation in the opposite direction but all that maths just gets confusing :S

v92

[url:gend5225]http://www.mediafire.com/?b7o4gpovvpyyl95[/url:gend5225]
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Sat Aug 14, 2010 4:22 am

It'll be a lot more complicated. It would involve ditching the entire rotate-towards-position action because it automatically chooses the shortest distance, and once you pass the 180 mark it will immediately reverse direction. Momentum would mean there would be carryover in the opposite of the desired direction for at least a few pixels.

You would have to calculate rotational acceleration and apply it manually with always set angle actions, letting positive values represent clockwise rotation and negatives for anticlockwise.

When the difference between the current and desired angles is between 90 and 180 degrees you would increase the acceleration towards the cursor, and when it's between 90 and 0 you would decrease it until it coasts to a stop at 0.

Since the only value we're modifying is acceleration, the slow turnaround would handle itself as the value nears and then coasts past zero. The tricky part is getting the system to understand which way to turn, especially when dealing with the 360 = 0 point.

Now that I look at it, the rotate-towards-position action will accept negative values. It might be possible to mess with this value to approximate the effect...

EDIT: Now that I look at it all written down, I think this code as written would cause it to simply rotate around the wrong way, because as soon as it passed 180 it would still take the shorter direction.
B
2
S
1
G
2
Posts: 35
Reputation: 870

Post » Sat Aug 14, 2010 1:18 pm

Thanks for the reply victrium :)

Yeah I started to figure out it'd take a lot more calculation - I did try this with the physics plugin before which worked to an extent, but was too unstable for me to be satisfied with :S Also, I'm avoiding using it now as those previous projects crash with the latest version of Construct.

It's easy to get this effect with WASD or cursor keys but so much more difficult when you have a target angle... I was hoping mouse control would feel a little bit more natural...

I've looked all over for examples and tutorials in other languages but had very little luck! :( I was hoping not to get lost in maths on this one, every project I start gets nowhere because a massive amount of calculation is needed for things to look right :P
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Sat Aug 14, 2010 8:12 pm

I think you could put a restriciton to rotating, put the angledifference as timer countdown before it is able to turn to other side, meaning it must slow down by decreasing angledifference before it can rotate to other side...
B
3
G
4
Posts: 54
Reputation: 1,183

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests