How do I set a animation based on mouse's position?

Get help using Construct 2

Post » Thu Jul 17, 2014 6:08 am

Hey there, im new to the community! Just got this amazing software a couple days ago and im still learning the basics before i can in fact focus on my own game. =D

But, im stuck for a while already, and i've searched everywhere, tried many different ways, but without success... Im trying to make my character run a specific animation as it moves to where i pointed with mouse (its moving ok to the position, but as a static sprite). I was messing around trying to get the mouse' angle, position, but it never worked for all 8 movement animations (4 diretions plus 4 diagonals). Someone enlighten me, please.

Thanks in advance! o/
Last edited by Warrada on Thu Jul 17, 2014 6:45 am, edited 1 time in total.
B
2
Posts: 4
Reputation: 158

Post » Thu Jul 17, 2014 6:31 am

which method (behaviour) are you using for the movement?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jul 17, 2014 6:40 am

LittleStain wrote:which method (behaviour) are you using for the movement?


Pathfinder.
B
2
Posts: 4
Reputation: 158

Post » Thu Jul 17, 2014 6:51 am

You can get the moving-angle of your sprite with the expression

Sprite.Pathfinding.MovingAngle
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jul 17, 2014 7:02 am

LittleStain wrote:You can get the moving-angle of your sprite with the expression

Sprite.Pathfinding.MovingAngle


Didnt work.. =/ Maybe i put them on the wrong place, but the system didnt recognize these expressions... Can you be more specific about how/where should i use this expression? sry, im a newbie yet..
B
2
Posts: 4
Reputation: 158

Post » Thu Jul 17, 2014 7:12 am

you probably want to know if the player's moving angle is between certain agles to switch animations, so this is how:

first set rotate off in the pathfinding properties.

(YourSpriteName) pathfinding is moving along path
System is between: (YourSpriteName).pathfinding.movingangle -between- 22.5 -And- 67.5
- set animation to down-right

(YourSpriteName) pathfinding is moving along path
System is between: (YourSpriteName).pathfinding.movingangle -between- 67.5 -And- 112.5
- set animation to down

etcetera..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jul 18, 2014 1:05 am

LittleStain wrote:you probably want to know if the player's moving angle is between certain agles to switch animations, so this is how:

first set rotate off in the pathfinding properties.

(YourSpriteName) pathfinding is moving along path
System is between: (YourSpriteName).pathfinding.movingangle -between- 22.5 -And- 67.5
- set animation to down-right

(YourSpriteName) pathfinding is moving along path
System is between: (YourSpriteName).pathfinding.movingangle -between- 67.5 -And- 112.5
- set animation to down

etcetera..



Hey, thank you so much for your help! It really works now the way i wanted! \o/

I was trying before with a different behavior (Pathfinder, instead of Pathfinding as you suggested), now the character moves really smooth in all 8 directions, except to the right, which is the spot that theres the angle between 340 and 20, and i dont know what i should put in the expression to make the 340 ''jump'' through the 0 instead of 'running' all the way back. Any idea on this? Its probably very simple but im still to newbie to figure it out.. lol
B
2
Posts: 4
Reputation: 158

Post » Fri Jul 18, 2014 7:27 am

No problem :)

for the 340/20 issue you can just use -20 and 20.. :)

Good luck with the rest of your Game!
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: guannstar, nahima and 20 guests