PlayMaker Feedback > Action Requests

speed changing from float interpolation

(1/2) > >>

santelia:
It would be nice if we could set speed using the output of a "float interpolate" action, with an "every frame" option. I mean in the same way as we already can set a scale using a value resulting from "vector3 interpolate".
As it happens in my case, it could be useful for managing movements of objects that need to accelerate, then move constantly toward a certain point, then brake when arrived at a certain distance. Or simply accelerate/brake.
Is there any workaround for that? I mean yet available?

Alex Chouls:
Have you tried Move Towards while controlling the Max Speed?

You can set Max Speed to a float variable and change it over time to clamp the speed at which the game object moves.

You can also combine lower level actions:

Vector3 Subtract to get a vector towards a target.
Vector3 Clamp Magnitude to clamp the speed.
Translate to apply the movement vector to a GameObject.

This gives you more control if you need other steps in there...

santelia:
Thank you Alex.
Following your suggestion, I'm trying to sort things out but I have to admit it seems not so obvious.
So, how would you structure the flow if your goal was as follows.
You've got a position (vector3) where your object have to move to.
You need:
1) accelerate for the first 5 seconds seconds and travel (along a straight path) for not more than N distance ranging from 0 to F max speed
THEN
2) proceed at at F fixed speed to a certain position
THEN
3) brake from F to 0 in the remaining N last distance.
? ;)

jeanfabre:
Hi,

 Have you though about using a pathfinding system? this kind of behaviour are the job of such framework. and you will gain a lot of potential useful feature as your game will evolve, for example obstacle avoidance, retargeting.

 Do you have unity pro or indie?

 Is your target moving or fixed? 

to do that manually:

the way you describe it is very much the way it's going to be design in the fsm. So you have three states, "accelerate", "cruise", "decelerate". I would however inject a state before that that turn the ship towards its target. so

"TURN"
"ACCELERATE"
"CRUISE"
"DECELERATE"


upon a global transition "MOVE BOAT" or something, get the direction of the boat etc etc and enter the state "ACCELERATE", in that state you move your boat at an increasing speed, in the same state you record the distance it traveled, and it move to the next state "CRUISE" once it reached a certain distance, and so on.

to mimic acceleration and deceleration, use the "translate" action and increase or decrease the value you inject in there using "float interpolate".
To detect the travelled distance, you can check the distance remaining towards the target or the distanced travelled from the start point using "get distance" action.

be aware that some initial check up would be required, if for example your target is closer than the acceleration and deceleration range, then you will have to accomodate for this for a realistic behaviour.

All in all, this kind of behaviour is quite a complex task to tackle, so be patient with this.

bye,

 Jean

santelia:
Sorry Jean I missed your reply. Not too late, indeed, to answer your questions.
No, at this stage of the project (actually two projects: one rts game and one sci-fi rpg), I'm using indie version. Since Unity v.4 is on the way to be released, maybe then I'll buy Pro.
As far as pathfinding systems are concerned, which one would you suggest based on flexibility and performance?
At this point of the development, nevertheless, I believe we've already done some steps forward with a specific project-taylored set of solutions, including some very specific new actions, and I wouldn't be very happy to restart from scratch just to integrate a commercial pathfinding if not compelled to.

Navigation

[0] Message Index

[#] Next page

Go to full version