How Do You Calculate moveTo() Time?
by practicing01 · in Torque 2D Beginner · 04/24/2013 (8:26 am) · 2 replies
Can someone please provide a function to calculate the time an object is supposed to take to reach its moveTo() destination? I'd like to schedule a function that deletes the object if it doesn't reach the destination in time. I tried the following code but got an assert (I tried remaking the engine's method and it didn't work).
//%dest & %position set before this %speed=10; %linvel=Vector2Sub(%dest,%position); %dist=Vector2Normalize(%linvel)*%speed; %time=(%dist/%speed)*1000;
#2
Edit: Made one that works:
04/25/2013 (4:45 am)
I do have the onmovetocomplete() callback set for the class of the object I'm dealing with. It's not being called for whatever reason, that's why I want to manually schedule a deletion (I have the deletion within onmovetocomplete and it's not being called).Edit: Made one that works:
%speed=10;//units per second (here we set to 10 per second) %time=((Vector2Distance(%position,%destination)/%speed)*1000)+1000;//+1 second to allow time for onmovetocomplete
Torque Owner Richard Ranft
Roostertail Games