Let's take a look at changing the shape properties of a MeshEntity.
Here's an example of increasing the size of a sphere when we pass it through a Trigger:
function Trigger:onEnter(obj) -- Verify we are dealing with a sphere before we attempt at setting its radius if (type(obj:getMeshModel():getShape()) == "SphereShape") then obj:getMeshModel():getShape().radius = obj:getMeshModel():getShape().radius + 0.3 end end
Notice that to get to the shape properties from the parent MeshEntity object, we need to first get the MeshModel (which is an object that stores the shape and material assignments) then call getShape() on the MeshModel. getShape() in this case returns a SphereShape where we can set its radius.
Comments
0 comments
Please sign in to leave a comment.