In this tutorial, I will show you how to make an infinite boulder which will be activated infinitely.
spawner = GetMoveableByName("Boulder_spawner")
boulder = Moveable(TEN.Objects.ObjID.ROLLINGBALL, "boulder", spawner:GetPosition())
LevelFuncs.OnStart = function()
boulder:MakeInvisible()
end
LevelFuncs.BoulderSpawn = function()
boulder:Enable()
end
LevelFuncs.resetBoulder = function()
boulder:SetPosition(spawner:GetPosition())
end
spawner = GetMoveableByName("Boulder_spawner")
boulder = Moveable(TEN.Objects.ObjID.ROLLINGBALL, "boulder", spawner:GetPosition())
This block declares and initializes 2 variables: – spawner variable which gets the moveable by its lua name set in Tomb Editor. In this case it’s “Boulder_spawner” and a nulllmesh (doesn’t matter which slot) – Boulder variable which creates a new boulder via the Moveable() function. To learn more about this function, read here: https://lwmte.github.io/2%20classes/….html#Moveable
LevelFuncs.OnStart = function()
boulder:MakeInvisible()
end
LevelFuncs.BoulderSpawn = function()
boulder:Enable()
end
LevelFuncs.resetBoulder = function()
boulder:SetPosition(spawner:GetPosition())
end
The OnStart command will make the boulder invisible since the engine will make the boulder visible so I made it invisible, however you don’t have to do this if you don’t want to.
Boulderspawn
function will simply trigger the boulder.
ResetBoulder
will reset to its initial position using the nullmesh.
—
Setup in TE
To set this up you need:
My test level looks like this:
The nullmesh at the top acts as a boulder “spawner”, the volume to the right makes the boulder trigger (activated by Lara), and the volume at the bottom resets the boulder position (activated by Other objects we do not want Lara to reset the position of the boulder.).
Let’s see how this looks in game!
Notes:
You don’t have to use the moveable()
function to create the boulder, you can just place it in TE, however there are scenarios that moveable()
can be very useful and used in an interesting way. One example is making an infinite random enemy spawner: https://github.com/Stranger1992/Tomb…Lua-Scripts#12
That is the end of the tutorial, let me know if you have any suggestions.