Hello there, I am writing a custom vehicle spawner for my spike strip mod. The goal is to spawn a spike strip behind a car. So far that works already with the "spawn.spawnVehicle()"-function, but it is not so fluid enough. The spawning process takes some time and pauses the game for a second. So I came up with the idea that I could spawn the spike stip once and then only set the position and the rotation but here begins the trouble. I could not find a "setRotation"-function and the "setPosition"-function does not accept, due to a type mismatch, my calculated position The ready to use script is in the appendix with the problem lines commented out (spikestrip\lua\ge\extensions\bluetac\spikestrip.lua). If you have another idea to make the process more fluid, tell me
I don't think that setRotation() is a real thing for a vehicle. Instead try vehicleSetPositionRotation(id, px, py, pz, rx, ry, rz, rw) or something like scenetree.findObject('thePlayer'):setPositionRotation(px, py, pz, rx, ry, rz, rw) As you can see, you'll need to break up that quaternion into individual values to punch them into the function. Since you've got the quaternion in the variable rot you can use rot.x, rot.y, rot.z, rot.w for the last 4 values in the function.
Some function to help you Code: quatFromEuler(0, 0, math.rad(90)) -- Need 0.12 for the getDirection* function -- `pv` is the vehicle object local dir = vec3(pv:getDirectionVector()):normalized() local up = vec3(pv:getDirectionVectorUp()):normalized() quatFromDir(dir, up) as @torsion pointed out, `setRotation` doesn't exist you have to use `setPositionRotation`
@torsion Thank you, setPositionRotation() works and thank you @thomatoes50 for providing additional informations But may I ask two more questions? Where can I find the beamengine methods? And where do you know that @torsion?
Most probably, he read a lot of code from the game to know what we are using and how. everything that start with `be:` is beamengine methods, you can search those using a text editor
thomatoes50 is correct. I've spent quite a bit of time reading Lua code from the game. I also do a lot of searching inside the official code in order to find what I want. I prefer to use Agent Ransack to locate useful sections and then Notepad++ to read it. Agent Ransack is also great because it displays 1-line snippets of your matches, so you can quickly see how a function is called. EDIT: I forgot to say you're welcome, and good luck with the mod.
Thank you and also thanks for the tipp with Agent Ransack. I will try it out. Currently I´m using Atom for searching.
Let me know what you think after you try it out. I've been using Agent Ransack for years, but I never compared it with other search utilities. If there's something better I'd like to know. To see the grep-like 1-line snippets be sure that the window is big enough. At a large enough size the window will display a pane on the left with file results and a pane on the right with all matching lines from the selected file result.