Implementing Smooth Movement and DeltaTime in Game

Software: Away3D 4.x

rustyk, Newbie
Posted: 26 March 2016 04:17 AM   Total Posts: 22


I’m porting a simple game from another engine that uses some kind of equalizing speed so it will be the same regardless of sytem spec.

I found there’s a solution in 2D (Starling) but not sure how this would be something similar with Away3D.

private function update(e:EnterFrameEvent):void
e.passedTime//passedTime is starling attribute


Player.+= movementSpeed deltaTime

I know there’s deltaTime for Away3D but I’m not sure how to use it. I can’t find any examples on web either (yet).




Yann, Newbie
Posted: 31 March 2016 09:28 AM   Total Posts: 16   [ # 1 ]


I’m not sure of what I’m going to write so I think you should wait for a confirmation
if you use an “animator” class ( for exemple the skeleton animator ) the motion is based on the time given by the function getTimer()

in the :

private function onEnterFrame(event:Event null):void

You can find some information about the getTimer here

but basicaly it returns the time spent since your application is runing. Whatever the system specs are.
So if your issue is to be sure that the motion will have the same speed on all the systems, you can trust in the animator class or build your own class based on the time returned by this function.
I hope this can help you


rustyk, Newbie
Posted: 01 April 2016 01:57 AM   Total Posts: 22   [ # 2 ]

Thanks. I was wondering why the above is not hooked in the player movement?


therealloft, Member
Posted: 01 April 2016 07:30 AM   Total Posts: 63   [ # 3 ]

This is what i would use

private var view:View3D;
protected function 
.camera.moveForward(view.deltaTime 10); //move camera forwards 10 meters per second

rustyk, Newbie
Posted: 01 April 2016 02:18 PM   Total Posts: 22   [ # 4 ]

Hey thanks therealloft! So I can just do the same for let’s say AI like this?

enemy.moveForward(enemy.deltaTime 10

this sure helped a lot.



therealloft, Member
Posted: 01 April 2016 04:25 PM   Total Posts: 63   [ # 5 ]

if you create a public static var to hold it, it be easyier like this

public static var deltaTime:uint 0;

protected function 
deltaTime view.deltaTime;

Then all you have to do from any part of you app to find deltaTime is call


hope this helps


rustyk, Newbie
Posted: 03 April 2016 01:29 AM   Total Posts: 22   [ # 6 ]

appreciate this added tip therealloft. will definitely try this out, thanks!



Away3D Forum

Member Login