Changing animation for T.M.P. project.

This forum is currently in read-only mode.
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • Hello!

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

    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).

    <img src="http://www.ii4.ru/images/287366move%20to%20front.jpg"> <img src="http://www.ii4.ru/images/417197move%20to%20back.jpg"> <img src="http://www.ii4.ru/images/527586move%20to%20left.jpg"> <img src="http://www.ii4.ru/images/752355move%20to%20right.jpg">

    Please, look at this "cap" file - http://www.fileqube.com/shared/gaJUscyUQ1470831

    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...

  • 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.

    <img src="http://i42.tinypic.com/qracyc.jpg">

    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.

  • deadeye

    This is a brilliant decision. Thank you very much!

    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): http://www.fileqube.com/shared/JGwKDd1471650 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • deadeye

    Ok!

  • This seems pretty solid:

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

    Things I changed:

    • You only need one face object, hehe (my bad)
    • The whole control retrieval structure
    • Control presses and face directions both populate a variable
    • Animation is decided on the value of both variables

    Other things I changed that aren't as important:

    • 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)
    • 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.
    • Arrows to WASD
    • "Key is down" conditions to "Control is down"
  • deadeye

    Cool!!!

    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!

    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)

    • Arrows to WASD
    • "Key is down" conditions to "Control is down"

    man, if only someone made a plugin that let you set controls at runtime

  • 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 - http://www.fileqube.com/shared/PjatUqDj1480636

    Thank you.

  • 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.

  • What is the desired behavior?

    I see it working fine, it shows the "walk forward" animation only when walking towards the pointer, same for the other directions.

    If what you're after is always having the feet point to the proper direction, then you would need to have them in a separate sprite. Since this seems to be 3D, you could render the torso again and then the legs, separately, then move them together and set the torso angle towards the mouse, while setting the legs angle according to keys.

    On a different note:

    man, if only someone made a plugin that let you set controls at runtime

    I lol'd.

    We need a thread for uploading custom plugins, yes.

    Whoa --> [quote:1q7iin1e]http://www.scirra.com/phpBB3/viewforum.php?f=29

    there is already. Lucid! upload!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)