Changing animation for T.M.P. project.

For questions about using Classic.

Post » Tue Jun 23, 2009 6:37 pm

Hello! :)

I want to change main character's animation (his legs) in my game ( [url:286pdkhr]http://www.scirra.com/phpBB3/viewtopic.php?f=4&t=3985[/url:286pdkhr] )

Please, tell me, if someone knows, how to set events, that animation will changing relating on the cursor position? i.e. when the sprite is moving towards the cursor, we set animation where it's moving forward. And conversely, when the sprite is moving in the opposite direction of the cursor, we set animation where it's moving back. Accordingly, when it's moving left or right - we set animation where it's moving to the left or to the right (moving sideways).



Please, look at this "cap" file - [url:286pdkhr]http://www.fileqube.com/shared/gaJUscyUQ1470831[/url:286pdkhr]
There is the scene, where the sprite has animation in 4 directions, and the cursor.

I've tried different events, but I can't get the desired result... :(
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Tue Jun 23, 2009 7:54 pm

Well, you could do it by getting the difference in angle from the torso to the mouse and the angle of motion for your player, but that's a lot of math that I wouldn't want to bother with so I'd just do something like this:

Make four detector objects that follow the player, but do not rotate. Next, set up a series of image points for your torso, one in each direction. When the image overlap the detector objects, they tell that object what animation should play when the player moves.



Then, when the player presses a movement key, pick the proper detector that matches the key, get the direction that's stored in the private variable, and play that animation.

It's low-tech, but it should do the trick.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Jun 24, 2009 10:23 am

deadeye

This is a brilliant decision. Thank you very much! :P

Everything works as I expected. But only sometimes, if I hold down two keys at the same time, the character animation freezes.

Here is my 'cap' file (what I've made): [url:3rrsj9wf]http://www.fileqube.com/shared/JGwKDd1471650[/url:3rrsj9wf] 952 kb.

I create events, where animation is activated by pressing direction keys and collision with a point on the object. Perhaps, that is reason why I have freeze animation. If I set events to run animation by private variable, as you wrote, will it fix this problem?
Or is there no difference between two these methods?
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Wed Jun 24, 2009 10:47 am

Edit:

I did have a post here but I realized after I posted it that it would be buggy, so never mind.

I'll take a look at your .cap later... it's past my bedtime :P
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Jun 24, 2009 11:00 am

deadeye

Ok! :D
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Wed Jun 24, 2009 8:53 pm

This seems pretty solid:

http://files.getdropbox.com/u/529356/move%202.cap

Things I changed:
[list:2xhn4a8x]
[*:2xhn4a8x]You only need one face object, hehe :P (my bad)[/*:m:2xhn4a8x]
[*:2xhn4a8x]The whole control retrieval structure[/*:m:2xhn4a8x]
[*:2xhn4a8x]Control presses and face directions both populate a variable[/*:m:2xhn4a8x]
[*:2xhn4a8x]Animation is decided on the value of both variables[/*:m:2xhn4a8x][/list:u:2xhn4a8x]

Other things I changed that aren't as important:
[list:2xhn4a8x]
[*:2xhn4a8x]You don't need to set the collision mode for objects every tick (or at all... you can do that in Properties in the layout) (actually that one is kind of important)[/*:m:2xhn4a8x]
[*:2xhn4a8x]I didn't see any need to change the speed of the 8Dir object so I removed those events, they have nothing to do with animation, you can set the max speed in a separate group of events. As for walking/running animations... well, recreate the walking animation section and change it for running. Put all the walking and all the running animations into separate groups, and activate/deactivate the proper group as needed. That would probably be the easiest way.[/*:m:2xhn4a8x]
[*:2xhn4a8x]Arrows to WASD ;)[/*:m:2xhn4a8x]
[*:2xhn4a8x]"Key is down" conditions to "Control is down"[/*:m:2xhn4a8x][/list:u:2xhn4a8x]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Jun 25, 2009 7:50 am

deadeye

Cool!!! :D

Yes! Now it's really cool spaceman with a very good mechanics of movement.

You have probably spent much time, I don't know how to thank you! :P

In general, thank you very much!

P.S. I would like to add you in the titles in the column of game developers (of course, if you don't have anything against) :)
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Thu Jun 25, 2009 8:08 am

[quote="deadeye":3kh723ra]
[list:3kh723ra]
[*:3kh723ra]Arrows to WASD ;)[/*:m:3kh723ra]
[*:3kh723ra]"Key is down" conditions to "Control is down"[/*:m:3kh723ra][/list:u:3kh723ra][/quote:3kh723ra]
man, if only someone made a plugin that let you set controls at runtime
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Jul 03, 2009 6:38 pm

Hello.

I've found one problem. I tried to solve the problem, but haven't yet fix it. Please, help me.
The problem is:
when I press D (moving right and the cursor right too) or when I press A (moving left, the cursor left) and at the same time I press W or S control - character's animation is playing normally.
BUT when I press W (moving forward, the cursor up) or when I press S (moving back, the cursor down) and if I press A or D - character's animation doesn't change! He is sliding and his legs don't go.
Please, if it's not difficult for you, help me solve this defect.

Here is cap file - [url:1gi523zj]http://www.fileqube.com/shared/PjatUqDj1480636[/url:1gi523zj]

Thank you.
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Mon Jul 06, 2009 2:20 pm

Hello!

Tell me please, is there another way to make that the character's animation is changing in motion for the cursor?

More details you can read in this topic in the first post.

Thanks.
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests