Alternative/Simpler way to move to position?

Get help using Construct 2

Post » Sat Feb 13, 2016 1:59 am

Message: Gamer M can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
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
Code: Select all
//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

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!

Image
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
B
10
S
2
Posts: 25
Reputation: 670

Post » Sat Feb 13, 2016 2:24 am

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
B
7
S
2
Posts: 56
Reputation: 583

Post » Sat Feb 13, 2016 3:10 am

dsminor wrote: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.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Sat Feb 13, 2016 3:46 pm

dsminor wrote: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?

Carbincopy wrote:
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?
B
10
S
2
Posts: 25
Reputation: 670

Post » Sat Feb 13, 2016 5:21 pm

Update: I tried what disminor said and it work. Thanks!
Here is the code at the code.
Image
B
10
S
2
Posts: 25
Reputation: 670

Post » Sat Feb 13, 2016 5:22 pm

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.
B
7
S
2
Posts: 56
Reputation: 583

Post » Sat Feb 13, 2016 5:28 pm

dsminor wrote: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. ;)
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Sat Feb 13, 2016 5:32 pm

Gamer M wrote:Update: I tried what disminor said and it work. Thanks!
Here is the code at the code.
Image


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.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317


Return to How do I....?

Who is online

Users browsing this forum: mrkaio, Zav and 2 guests