Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Splankton on October 31, 2013, 11:15:24 AM
-
Hi I need some help with a calculation I need for a timer I have counting down.
Basically, I have a player that moves around using a speed variable and a simple countdown timer. Also a distance variable that checks from player to a home base object.
And what I need using these 3 variables is to check what would be the latest time left for the player to make it back to base.
Can someone help me out I'm pretty sure it's a simple calculation, but my math isn't the best ;-)
-
Hi,
ok,
the distance is equal to the speed*time
so if you know the remaining distance and the speed, and want to know the time it will take:
time = distance/speed
Try this, and let me know how it goes,
bye,
Jean
-
Hi,
ok,
the distance is equal to the speed*time
so if you know the remaining distance and the speed, and want to know the time it will take:
time = distance/speed
Try this, and let me know how it goes,
bye,
Jean
Thanks Jean. So I have a time float variable, a distance float and speed float variables.
On the object that I want to move back to base in the time left, I have a FSM -
Get Distance (store result to distanceToBase)
Float Operator (float 1 = distanceToBase)
(float 2 = speed)
Operation (divide)
Store Result (my time float?) or a new float?
So, if I have that setup right, (do I store the result in the variable I'm using for time, or in a new float?)
I need to SetDestination in the Navmesh, to base at some point, but I dont know how to use that stored result for what I'm after.
Also, to add to the problem, I'm using a terrain with objects that are set as static. So, whatever time it will take to return back to base, it will always be too short because the route back will not be a straight line.
thanks for any help.
-
Hi,
-- Using the action "getAgentRemainingDistance" you'll know the actual distance left for the current path/destination it's seeking.
-- Using the action "GetAgentVelocity" you'll know the current speed.
Then you can work out the time left.
You need to store the result in a float for sure, call it "Time left" or something, then you can display that "time left" value to the user in your UI.
bye,
Jean
-
Hi,
-- Using the action "getAgentRemainingDistance" you'll know the actual distance left for the current path/destination it's seeking.
-- Using the action "GetAgentVelocity" you'll know the current speed.
Then you can work out the time left.
You need to store the result in a float for sure, call it "Time left" or something, then you can display that "time left" value to the user in your UI.
bye,
Jean
Thanks Jean. Where can I find that agent action?
It's used for a NPC so I want it to set the navmesh gohome when the distance is too far away from the base.
-
Hi,
It's an Addon:
http://hutonggames.com/playmakerforum/index.php?topic=1253.0
Bye,
Jean
-
Hi,
It's an Addon:
http://hutonggames.com/playmakerforum/index.php?topic=1253.0
Bye,
Jean
Thanks, I'll have a look.