Looping ground for character to run on, but gets pushed back on collision

chongyunxiang

  • *
  • Posts: 278
Hi,

I'm creating a looping ground for the character to run on. Able to make the ground loop, but character gets pushed back after a while. How do I solve it? The group for the ground is under Tiles and I make Player collides with Tiles and vice versa.

Thanks!

« Last Edit: September 08, 2015, 10:12:06 am by chongyunxiang »

MichaelPel

  • *
  • Posts: 458
Hey

If I understood correctly, you have a tile under the player that moves? Could you post a screenshot of the scene? It would be easier to help you if I knew what you're doing (platformer, or rpg-maker styled bird's eye view etc)

chongyunxiang

  • *
  • Posts: 278
I have an actor underneath the player that moves and I placed that actor under the group Tiles. Hope the screenshots help!

Thanks!

MichaelPel

  • *
  • Posts: 458
This seems like the player doesn't move horisontally, but the map does it for the player. If the player is always supposed to be in the center of X-axis, you could for example make an "always if X of self is not screen width / 2, set X of self to screen X / 2. The reason the player gets dragged is friction; your ground essentially behaves like an elevator / moving platform. I'm not currently on the computer, so I can't check, but you can also set the player's physics settings to > cannot be moved. I have't used it myself before, but as far as I know it makes it so things can't be pushed (or in this case, dragged). I will be able to provide you with a working example with screenshots of code once I get home.

chongyunxiang

  • *
  • Posts: 278
I tried the Cannot Move as well as Cannot be Pushed options for the character, but it makes my character phase through everything and stuck it's stuck in a frame in an animation. I'm pretty sure it's the ground that is being loops that causes my character to hit the newly created one, then causing it to get pushed back.

A screenshot of your code would help. Thanks!

MichaelPel

  • *
  • Posts: 458
Hey. Here's basically how the player stays still. I've attached a working tech demo you can open in stencyl to edit as you please, even threw in some graphics to get you started (you can use them if you want)

EDIT: So pick something, like screen X divided by 2 to get the center for example, and have your player always be there.
<a href="http://www.filz.us/files/35eaf0f0/06f/flash.swf" target="_blank" class="new_win">http://www.filz.us/files/35eaf0f0/06f/flash.swf</a>

chongyunxiang

  • *
  • Posts: 278
Awesome! All I did was to use the Set X to __ block for self and it works. Problem is that the character phased through the objects, because there will be obstacles and if character hits it, it'll be pushed back.

But I solved that problem by implementing that block to an If statement: Always -> If GameOver = False -> Set X to 64 for Self

Now the character will always stay in that position. And if it hits an obstacle, it'll switch GameOver to True.

Now I'm trying to make everything stop when character hits obstacle.

Thanks, really big help!!

MichaelPel

  • *
  • Posts: 458
For terrain and everything; Always IF GameOver = false then set x-speed to number, OTHERWISE set x-speed to 0

chongyunxiang

  • *
  • Posts: 278
Yup! Did just that! Thanks!