Tile Based Movement?

svd91

  • Posts: 39
Hi,
how would you create a tile based movement for an actor?
What i have:


Works fine, the actor always moves 32px every time i press a controll.
The problem is the actor doesnt get collisions anymore, because he is "teleporting" to the new position.
Any idea how to fix this?


Photon

  • Posts: 2691
Hi there,

I used this and found it very good :)

https://photongamedev.wordpress.com/2013/07/26/basic-grid-based-movement/comment-page-1/
Unfortunately, I think my approach has  the "teleporting" issue to deal with as well, though its nice if you want to make your movements more fluid.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

svd91

  • Posts: 39
Thanks for the link, unfortunaly it seems to work like "StepMovement" from the Forge. And it has the same problem :/
Any other ideas?

ohlin

  • Posts: 71
Is it possible to use motion set very high, and limited to 32px per move, and also enable continuous collision detection?

svd91

  • Posts: 39
Hm, how would I do that?

ohlin

  • Posts: 71
This is just a thought, but you would have to set two number attributes to store your current position, start the motion, and calculate when they have been increased/decreased with 32 pixels, and then stop the motion. That way you won't teleport into the region, but enter it the "normal" way.

The continuous collision detection might not be needed. Also, there might be some easier solution to it, but this is what I would try out.

Northfield82

  • Posts: 649
Hi mate,

I think your problem is the same / similar as one I faced when trying to do a Frogger type level for my game.  I wanted the character to move in grid spaces (32px) but to actually walk and not teleport so he could get hit from objects coming from either side.

Anyway, here is my Actor Behaviour.

Step Length = 3.2
Step Interval = 0.02
Grid Space Dimension = 32

Good luck hope it helps

svd91

  • Posts: 39
Like this?


It works, almost ::)

The Problem is the actor can either move left and right, or up and down. but not al together


In this picture he could move left and right, but i'm not able to move down

svd91

  • Posts: 39
@Northfield82

Thanks, ill try it and report back :)

Northfield82

  • Posts: 649
I've posted it to stencyl forge under '4 way behaviour'

svd91

  • Posts: 39
I've posted it to stencyl forge under '4 way behaviour'

Thanks:) got it.

okay it works better than what i had :D
But the actor gets slower over time?! First when i press right he move 32 px, second time he move 31 etc always one px less then before.

Northfield82

  • Posts: 649
ooh, not sure, not noticed that...

My screen size for that particular level is only 320x480 so I've not had to move him that far, sorry.  Sounds like a step in the right direction though :)

svd91

  • Posts: 39
Yes it it is :) thank you evry much

svd91

  • Posts: 39
So if got it:



What it does is too check the tile next to you in the direction you want to move.

e.g. if you press right it checks if the tile on the right of your actor is a tile with an ID of 0 or 1. If it is, move.