Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Scene:update doesn't seem to pass the dt parameter to added objects

in Codea Craft Posts: 1,089

Added a simple mover class to the Cameras example in Learn Codea, and added an instance with entity.add. The mover update is called but dt is nil. I had to use DeltaTime directly to do my moving:

RonMover = class() function RonMover:init(entity) self.entity = entity self.speed = 1 end function RonMover:update(dt) -- print(dt) local x = self.entity.x if math.abs(x) >= 2 then self.speed = -self.speed end x = x + self.speed*DeltaTime -- dt is coming back nil FSR self.entity.x = x end

And in the existing code, I added the add line below:

myEntity = scene:entity() myEntity.model = craft.model("Blocky Characters:Orc") myEntity.y = -1 myEntity.z = 0 myEntity.scale = vec3(1,1,1) / 8 myEntity.eulerAngles = vec3(0, 180, 0) myEntity:add(RonMover)

The print in update prints nil always.

Whazzup? Thanks!

Sign In or Register to comment.