Alternative/Simpler way to move to position?

0 favourites
  • 8 posts
From the Asset Store
Template for an alternative to falling shapes, fully documented in comments and video
  • Hello.

    I'm trying to make an object(car) move/"teleport" left and right through 3 lanes using the keyboard controls. There is a solid brown barrier on the right, and I don't want the object to wrap. My first thought was to do

    //using A & D as left and right controls
    Event: D was press on keyboard 
         Actions: If car is in the middle lane (check position) then object.x +50 (how much move on x axis)
                 Else if object is in the right lane & Solid boarder is not near then object.x +50
    [/code:1k3fzn04]
    And so on so forth.
    But by doing this, it would take more time to make it perfect, and vulnerable to human error. What are some alternative/simpler ways you can do this? Open to any plugin and behaviors. Thanks!
    
    [img="http://i.imgur.com/I86ChJr.png"]
    [h2]Screenshot of the game that i need help with. (The graphics are WIP, but the car was base on a good concept    https://goo.gl/HBalpP[/h2]
  • I would make a variable called lane.

    left lane =1

    middle lane= 2

    right lane = 3

    on D press

    if lane not = 3

    set position car.x+50

    lane+1

    on A press

    if lane not =1

    set postion car.x-50

    lane-1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would make a variable called lane.

    left lane =1

    middle lane= 2

    right lane = 3

    on D press

    if lane not = 3

    set position car.x+50

    lane+1

    on A press

    if lane not =1

    set postion car.x-50

    lane-1

    I like your information about changing lanes, but I would use moveto and rotate towards or set angle while moving.

  • I would make a variable called lane.

    left lane =1

    middle lane= 2

    right lane = 3

    on D press

    if lane not = 3

    set position car.x+50

    lane+1

    on A press

    if lane not =1

    set postion car.x-50

    lane-1

    Thanks dsminor. This will make it less likely for human error. What will each lane varilble equal i may ask? Would it be specific lane coordinate for each one?

    I like your information about changing lanes, but I would use moveto and rotate towards or set angle while moving.

    How would i implement moveto and rotate towards or set angle for this instance?

  • Update: I tried what disminor said and it work. Thanks!

    Here is the code at the code.

  • The variable is just the number of the actual lane.

    1 for left lane

    2 for middle lane

    3 for right lane

    You dont need the exact coordinates unless the car is able to change its position inside its lane.

    If the car is fixed on its lane it should allways be the same distance to the next lane.

    I think what carbincopy wants is to actualy move the car to the next lane instead just "teleporting" it.

  • The variable is just the number of the actual lane.

    1 for left lane

    2 for middle lane

    3 for right lane

    You dont need the exact coordinates unless the car is able to change its position inside its lane.

    If the car is fixed on its lane it should allways be the same distance to the next lane.

    I think what carbincopy wants is to actualy move the car to the next lane instead just "teleporting" it.

    yes! I would make it look like the car is driving to the next lane.

  • Update: I tried what disminor said and it work. Thanks!

    Here is the code at the code.

    global (lane) = 1,2,3

    and uses the compare if lane = 1 no left movement

    and if lane = 3 no right movement

    per the picture, but could be used for up and down movement also.

    looking good. so far have fun. Jeremy C.

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