Platform movement problems

  • Hello fellow Constructors!

    I was learning the movements and animations in a platform environment.

    I downloaded a free sprite to test with.

    I found some problems that i would like to ask the community about.

    I have recorded my problem in this video: youtu.be/gGuBCmUJICo

    1. My "Idle" animation is working when i add my sprite on an empty space without ground. But when i add a "solid" ground under it, it jumps a bit. Can i configure this in some way?

    2. When i move forward i want to add the animation "run" to my sprite, i havent done it yet but when i move forward the sprite sometimes fall under the "solid" ground. So my question is; how can i work the ground better.

    3. The last thing i want to ask about is; what is the best way to reset an animation? like when i add animation "run" when i press forward on an arrow key, i want it to reset to "idle" when i release the movement. ive noticed the same problems when jumping and shooting.. the sprite stays in the last animationpart of that animation. I want it to reset to "idle"

  • Hello trainstation

    make sure that you set all collision polygons of your animations and frames properly.

    Second, check the origin of ALL your frames. In platformers, the origin is usually right under the feet of the character.

    To go back to Idle, you could use the condition 'Player is moving'(invert) -> set animation "Idle"(play from beginning).

  • Issues 1 and 2 are from incorrectly positioned Origin point and wrong collision polygons in frames.

    Ideally Origin point and collision polygon should be identical for all frames in all animations.

    A very common approach is to use an invisible sprite (simple box) with Platform behavior for controlling the character. And pin your character sprite with all animations to that sprite. Then you will not have all these issues.

    Question 3 - here is a good example of managing animations in platformer:

  • Thank you so much for great answers!

    The idea with the invicible box behind the character. Is there a tutorial for that somewhere? it seems to be a great way of doing it. By tutorial im thinking, how you pin all the movements to the same box and so on.

  • There was a tutorial for that but i cant find it now that scirra.com dont work anymore. But you can open C3 and load 'Kiwi Story'. It is a good example.

  • There is nothing difficult about it.

    Make an invisible sprite PlayerBox with platform behavior.

    Make another sprite PlayerSkin with all player animations and Pin behavior.

    Pin PlayerSkin to PlayerBox on start of layout.

    Use PlayerBox in all events related to Platform.

    Use PlayerSkin to control character appearance.

    For example:

    PlayerBox On Jump -> PlayerSkin set animation to "Jump"
    On Left key pressed -> PlayerSkin set Mirrored
    etc.
    

    I'm sure you can find many examples in Tutorials section:

    scirra.com/tutorials/all

  • I am so grateful for all your support guys.

    So i have been working a bit and ended up with some more questions ^^

    Here is an updated movie on how far ive come now: youtu.be/wwRyn7-Xsc0

    1. So as you can see in the movieclip, my character wont do the jump animation if i add another animation like in this case the run animation. And except for that, as you can see; the caracter is doing the running animation some seconds after ive stopped moving. Why is this?

    2. If i want to add a "longer" level, do i have to stretch the gamearea as long as i want the level? or is it some smarter way of doing it?

  • You should post your project code, not videos of the gameplay :)

    See my first comment in this post, if you copy all events from the screenshot, all your animations should work correctly.

  • I see now. Thank you again. I made it work now thanks to you guys.

    Im going to spawn a bullet now. I post the code. The thing i cant figure out now is; how do i make the bullet work on moth ways, mirrored and not mirrored. And how do i adjust my bullet to spawn lesser times. right now it spawns alot of bullets when i hold the shoot button. could you configure it with timescale or something?

    I tried to check tutorials but cant find exactly what im looking for. The bullet also spawns from the middle of the characters body. Im trying to change the startpoint but it gets wrong.

    imgur.com/a/msOLv16

  • You can define another imagepoint on the tip of the weapon in your Player sprite (you'll have to do it in all frames of "shoot" animation). Spawn bullets from this image point.

    Create a sub-event under your "spawn bullet" and add this:

    Player is mirrored -> Bullet set angle of motion to 180 degrees

    .

    To spawn less bullets you can add another condition "Every 0.2 seconds" under "Keyboard Z is down".

  • Thanks! it works! great help.

    If i want to increase the length of my level, do i have to make a "longer" screen or can i think in someo ther way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And another thing im thinking about is; i got an animation where my character shoots in mid-air. different from where the character is standing and shooting. if i want to add that animation..

    First i was thinking: playerobject --> on jump --> then i lost that one..

    next i was thinking: keyboard Z is down --> but then.. bah i cant get the logic in this haha.

    the character need to be in "jump" in air. and there the animation "jump shoot" should be able to play.

    I also got a slide animation where i want to activate a fast forward slide on a button hit. how can i make the button push the character faster forward a bit?

    Its like "if, else and while"-stuff i need.. but how do i implement it. i get the thinking but not how to.

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