How do I alternate between Tile Movement and Platform?

0 favourites
  • 3 posts
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • Hi :)

    I'm trying to alternate between these 2 movement behaviors.

    Briefly, my character uses tile movement while underground and platform while above ground.

    My idea is to enable/disable accordingly.

    The problem? When I enable Tile Movement my character goes back to the last position where tile movement was enabled.

    I'm thiking it keeps track of the X and Y coordinates it is in and when I enable the behavior it sents me back to that place. I want to avoid this.

    Is there any way? I'm trying to think of something like checking which are the grid coordinates of my current location and then use set them when I enable the tile movement but I can't find such a thing

    Thanks in advance!

  • I'm trying to think of something like checking which are the grid coordinates of my current location and then use set them when I enable the tile movement but I can't find such a thing

    Yes, this may work. If you have a tilemap, you can use Tilemap.snapX(player.x) and Tilemap.snapY(player.y) expressions to place the player to the center of the current tile.

    If this doesn't work, you can try MoveTo behavior instead of TileMovement. For example:

    On Left key pressed
    Player is Not moving
    .... Player Move To (self.x+50, self.y)
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for your answer dop2000!

    I didn't do exactly that but it gave me the idea I used!

    I just get the current player coordinates and divided by 32 (because my grid is 32x32) and then substract 1 because grid actually starts at 0. I also use int() so the number is rounded cause I don't want to be offset of the grid.

    Thank you for your help, it inspired the solution

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