How do I lock my player on only designated spots?

0 favourites
  • 9 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I am making a game that is required for the player to only teleport from one spot to another (Something like Tommy Q: Zombie Defender where the player moves from row to row), but after a while searching on tutorials and How do I..? I still cannot find anything that can help. The closest thing I ever found is a post name "How do I teleport my sprite to a given location?" but the answer file is broken or something. If you find or know anything that can help me please answer it down below. thank you in advance.

  • 'Set position' can be used. If you need something more specific please explain as I've not played that game.

  • What I think of doing is something like there are 3 points in a triangle if you press the > button the player teleport to point 2 and if I press it again the player teleport to point 3 and if I press < the player teleport back to point 2. Sorry but this is the best I can describe it, English isn't my first language.

  • This is what I got from your description.

    A simple permutation of the position, based on image points set in the sprite "Triangle".

    An instance variable "curPoint" (current point) is used to keep the current image point Player needs to be positioned on.

    If this does not suit your needs, please consider posting a .c3p example of what you currently have, and detail what you are exactly willing to do.

    Drawing pictures of what you are looking to achieve, might help.

  • Thank you for the help, this solves pretty much half of the game for me.

  • after a while of trying to replicate your file, I ran into some problems that I can't figure out

    I got something like this

    drive.google.com/file/d/1ZVLvY1E1uuMqSv6uC4CxCAVL5ThLhgjQ/view

    The problem is that I tried to instead a single button making the player going one way (clockwise). I tried to make another input to make it go another way (anti-clockwise) but when the player is at image point 1 they go to the origin point and get stuck there for a few taps (it's hard to describe it so if you can please download the file and try it).

    Is there a way to fix this?

  • This requires a bit of changes to the logic.

    Hopefully, you will get it quite easily.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thank you so much for your help. If I understand it right that means instead of going all around I set myself back whenever I'm nearly "stuck" is that correct?

  • I guess you could say that.

    Modulo (% operator) will only work with numbers greater than 0. So the operation works when adding 1 to Player.Position

    When subtracting to Player.Position, you need to make sure when the value is 0 and "jump" to the higher imagePoint value available.

    And to keep it consistant, when adding, "jump" over the 0 value, as 0 represents the origin point, which you do not want to ever use as a potential position when setting the position of the Player object to an image point of Triangle.

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