Getting a vehicle to follow a track
by Matthew Medina · in Torque Game Builder · 10/14/2006 (4:27 pm) · 8 replies
Hi, I've searched around, and could not find anything that answers my question.
I'm making a game that's played in a top-down veiw, where the player moves freely thoughout the level in a vehicle. At certain points in the levels though, I want it so the vehicle has to hook up to a track, like a train, and you only have to hold the up key and it will follow and turn along the track, and then when it reaches the end, unhook from the track.
The problem is I can't figure out what to do to get my vehicle to hook onto the track, and follow it. I thought there might be an option in the collision menu that would have it attach, but I couldn't find anything that works. So far, the only script I've set up is the players simple "up", "down", "left", and "right" movement, for when the player is not on the track. I'm guessing I'll have to create a script to get it to hook on and follow the track, could anyone please tell me how I can get this to work? Sorry if this is a simple question, or impossible, I'm new to this.
I'm making a game that's played in a top-down veiw, where the player moves freely thoughout the level in a vehicle. At certain points in the levels though, I want it so the vehicle has to hook up to a track, like a train, and you only have to hold the up key and it will follow and turn along the track, and then when it reaches the end, unhook from the track.
The problem is I can't figure out what to do to get my vehicle to hook onto the track, and follow it. I thought there might be an option in the collision menu that would have it attach, but I couldn't find anything that works. So far, the only script I've set up is the players simple "up", "down", "left", and "right" movement, for when the player is not on the track. I'm guessing I'll have to create a script to get it to hook on and follow the track, could anyone please tell me how I can get this to work? Sorry if this is a simple question, or impossible, I'm new to this.
#2
10/15/2006 (7:14 pm)
Try look on paths.pdf on your tgb documentation/tutorials/feature tutorials
#3
10/17/2006 (7:31 pm)
Thank you, that tutorial helped me a lot, but is there any way to have it still follow only the path, but let the player be able to control if it goes foward, backwards, or stops on the path with the keyboard?
#4
try looking method that suit you
i'm sorry i couldn't help you much .
i'm also a begginer too =p
10/18/2006 (6:48 am)
Hmmm i don't quite understand i think u should look on tgb reference.pdf on t2dpathtry looking method that suit you
i'm sorry i couldn't help you much .
i'm also a begginer too =p
#5
10/18/2006 (4:10 pm)
He want to control the speed of the player/vehicle on the track. Not its direction.
#6
speed is on title "pathing "
i see that on path.pdf page 3 - 4
10/20/2006 (5:36 am)
I think there is a speed properties on the pathed objectspeed is on title "pathing "
i see that on path.pdf page 3 - 4
#7
10/21/2006 (8:43 pm)
Yes, you can change the speed, but my main problem is controling when it the vehicle drives and when it stops. I want it so that the vehicle will only move along the track if the player is holding down the movement key, and stop when the key is let go, but with the path options it seems I can't control it and it just keeps going. I was wondering if it's possible to get the vehicle to only move forward on the track when I hold the movement key and stop when I'm not.
#8
function set_path_speed(keypressed)
{
if keypressed == up {
speed = -5
} elseif keepressed == down {
speed = 5
} else {
speed = 0
}
}
then bind your function (with parameters) to a key. Of course, the else isn't really going to work like I stated, but you get the idea.
10/22/2006 (12:38 am)
Umm... this is just psuedo-code, I haven't even looked at pathing, and I'm horribly intoxicated:function set_path_speed(keypressed)
{
if keypressed == up {
speed = -5
} elseif keepressed == down {
speed = 5
} else {
speed = 0
}
}
then bind your function (with parameters) to a key. Of course, the else isn't really going to work like I stated, but you get the idea.
Torque Owner Michael S
so your vehicle can follow the track