After some recent discussion, I've gotten the hankering to create a proof-of-concept for a 'looping' level, wherein the player is teleported to the opposite side of the level after hitting one if its edges. To work seamlessly, however, the teleportation needs to only alter one of the player's coordinates, not all three. I've adopted the teleporter code from Nadeox's simple_map, but every attempt I've used to retrieve the vehicle's position has raised errors. Most of the code I use for that sort of thing is used in scenarios, but I'm trying to make this work in the level itself, so I'm not sure if the scenario code should be compatible.
Here's the code I'm working with. It's not set up to do anything with the position information it gets from the player, but getPosition causes an error (nil value), so I haven't really had the need to write the rest of the code. Code: local function teleportPlayer(data) local vehicleName = data.subjectName local vehiclePos = vehicleName:getPosition() if data.event == 'enter' then TorqueScript.eval(vehicleName..'.position = \"-200 -200 0.05\";') end end return teleportPlayer
Code: local vehObj = be:getObjectByID(data.subjectID) local vehiclePos = vehObj:getPosition() vehiclePos.y = vehiclePos.y + 50 vehObj:setPosition(vehiclePos) only in LUA
Ah, I see. You need the vehicle's ID, not its name. The only issue that this code creates is that the first time this code is used, the vehicle resets both its position and orientation/momentum, so I'll have to see if I can augment the two scripts. nvm - happens with both scripts.
when you move the position of one vehicle object, it will always us this new position as a respawn position
Hey I know this is old and a bump, I've noticed when a car is falling, and I freecam & move around and hit f7, it does exactly what you want - teleports the car keeping the momentum & trajectory. Just look up that code in the game itself. I'd like to know if you ever solved this one!