I am working on a scenario where you have to drive up a slope whilst non AI dummy cars roll down the hill at you. I have a trigger box set up at the bottom where the dummy cars will contact and at that point I want the dummy car to be teleported back up to the top. I have been looking at the teleporting on Nadox1's Simple_Map but looking at the items.level.json.. Code: {"name":"teleport_trigger_carreturn","class":"BeamNGTrigger","persistentId":"5147879f-1288-4ab6-b6cb-cc5df2e1c101","__parent":"teleports","position":[-20,10,0],"TriggerMode":"Contains","luaFunction":"local function teleportPlayer(data)\n local vehicleName = data.subjectName\n\n if data.event == 'enter' then\n ui_message({txt=\"Teleporting to Skydome...\"})\n TorqueScript.eval(vehicleName..'.position = \"-2000 250 75.5\";')\n TorqueScript.eval(vehicleName..'.rotation = \"0 0 01 180\";')\n end\nend\n\nreturn teleportPlayer","rotationMatrix":[1,0,0,0,0.9999997615814209,-0.0006905338959768414,0,0.0006905338959768414,0.9999997615814209],"scale":[6,6,6],"triggerColor":[9,255,0,45]} {"name":"teleporttext_skydome","class":"TSStatic","persistentId":"11cc6f55-01b5-4ef0-ab20-db5c1b7a6d1a","__parent":"teleports","position":[-20,10,0],"instanceColor":[0.8999999761581421,0.300000011920929,0.300000011920929,0.5],"scale":[3,3,3],"shapeName":"levels/simple_map/art/shapes/BBZ_teleport_skydome.dae","useInstanceRenderData":true} {"name":"teleport_1","class":"TSStatic","persistentId":"4aeb1b27-394e-4157-8644-fcb305094297","__parent":"teleports","position":[-20,10,0],"instanceColor":[0.8999999761581421,0.300000011920929,0.300000011920929,0.5],"scale":[3,3,3],"shapeName":"levels/simple_map/art/shapes/sr_teleport.dae","useInstanceRenderData":true} {"name":"teleport_trigger_carreturn","class":"BeamNGTrigger","persistentId":"1b76d9e9-20ff-4b52-ab36-c030885c4e34","__parent":"teleports","position":[-2055,250,63],"TriggerMode":"Contains","luaFunction":"local function teleportPlayer(data)\n local vehicleName = data.subjectName\n\n if data.event == 'enter' then\n ui_message({txt=\"Returning to spawnpoint..\"})\n TorqueScript.eval(vehicleName..'.position = \"-0 0 0.5\";')\n end\nend\n\nreturn teleportPlayer","rotationMatrix":[1,0,0,0,0.9999997615814209,-0.0006905338959768414,0,0.0006905338959768414,0.9999997615814209],"scale":[6,6,6],"triggerColor":[9,255,0,45]} I am thinking that the teleporting is setup using Torque3D (editor). Does anyone have any experience with this? I would be very happy to learn the process. Thanks for your time.
Don't look at the json, but at the 'triggers' from the editor, easier to understand. You only need a 'BeamNG Trigger'. In the lua function you paste the same code I use for any of my teleport triggers, and adjust it to your preference (mainly the destination coordinates and message to print). That's it.
Ah, I see the process. I have it working now thanks. However there might be some bugs. Some of the cars are teleported with zero velocity and at the correct rotation an position that I specified, then some are teleporting but maintaining there speed and rotation factor. I would prefer them to maintain their current speed and heading. --- Post updated --- I am also getting further issues. After starting a fresh my docs folder and deleting all the repo mods I am getting problems after the first restart after the teleport has been used, shattered wheels and worse.. As you can see, the effect is not any good if the vehicles teleport and are stationary. I am sure that this is useful for other things but is there a way to specify them to maintain velocity and heading? This would reduce the risk of teleporting inside of each other and would make for a more interesting experience I feel. Thanks again for your time. --- Post updated --- Here is what I am working with. https://drive.google.com/open?id=1HEl3BgSJIbQyEskNGIDbDEoETYYurTtY Perhaps it has something to do with the half pipe being stretched so much, maybe I should use many in a row rather than scaling one up to the length that I need.
I have narrowed down the issue with shattered wheels and exploded physics, it happens when you restart after your car being teleported within another car and stuck together, resetting again once fixes some of it but I get weird noises and more bugging out, if I reset many times then it seems to be ok. It would be great if there was a way to cue the teleportations so they re-materialize once every few seconds. Here is some more footage
Sorry if you are busy but do you have any insight on this at all please? Or is it a bug that I will have to wait to be fixed?
If you have two vehicles going through the trigger at the same time, they will get teleport in the same place together, meaning issues. Only way to avoid that is making sure they never enter the trigger together. For the rotation/momentum, that's pretty random. For the others issues, no clue as I never seen them (note I haven't tested the triggers much with other vehicles than the player one)
I've toyed a bit with teleporting. The trick with momentum is that you can only set the vehicle's position, not its orientation. If you set the orientation to anything but what the vehicle's orientation was already set to*, the vehicle will reset, losing damage and momentum. *This usually results in vehicles being set to the same orientation repeatedly resetting only the first time.
You are a star! I removed the rotation specification and now they teleport as I want them too I just need to find out how to cue up the teleportations so that they don't spawn together. Thanks for your help.
If anyone wants to try these out. Here is the uphill and downhill versions of the GridMap experiment. https://drive.google.com/open?id=1D_fg377YykJiS1elSjBtxbdIG5zvwpFG
I would suggest having the cars with more powerful engines, not modded. They look like they would struggle to get up the hill WITHOUT anything falling down.
I know this isn't my thread or anything, but it fits quite well. How do I get the co-ordinates for a teleport LUA?
Move your vehicle in the editor where you want it to 'teleport', and copy the coordinates from the sidebar (in Object Editor mode). Paste those coordinate in the trigger code.
The idea is that you select whatever car you want at this stage. I will be working on it for the rest of the week now I am on leave from work again. I am thinking of another map very similar but where you have a zig-zag road up the hill, where on each straight, you have to cross past the falling stuff. Also a Pigeon avalanche too. --- Post updated --- If you make anything that you think is good, please show us --- Post updated --- Ok, I just had a light bulb moment. If I make many triggers at the bottom that all have a slightly different position to teleport to at the top then there should be no more multi-spawn madness. I will have my work cut out now as the optimum way in my book is a grid of triggers like 1m2 large. I could use math to work out the coordinates of the positions so it shouldn't be too hard, just time consuming, but hey, I have 4 days off lol.