make character move and interact by itself final fantasy style
so i want to make lets say "cutscenes" but they are not actually cutscenes, you know in older games when you get to some plot important point sometimes characters will start moving and talking on his own? thats what i want to do but i dont habe any idea where to start. tought of making this by code but it will be lots of code for all the scenes and that does not look like the best option, any advice on how to do it without code or if it is posible?
maeby its usefull to know, im planing on using orkframework and dialog system for unity assets, maeby they include an option for this?
[bump] some has any idea? anything is usefull at this point
@zolutr Unless I miss understood your question my answer below should be a great starting point for what you want to do. Have you had a chance to try it out?
Answer by starr_stealer · Oct 11, 2016 at 07:39 PM
I've seen a lot of users recommend iTween for this, I have not used that tool so I can't speak much about it.
Below is very basic idea of how you could do it, would need tweaks for your task, and handle performance impacts, etc. As well as handling smoothing, (ie the 3rd arg of Lerp)
void MovePlayerScripted()
{
float delayTime = 0.0F;
StartCoroutine(WaitAndMovePlayer(delayTime));
}
IEnumerator WaitAndMovePlayer(Vector3 newPosition, float delayTime)
{
// this is just to show how you could instruct it to wait before moving
yield return new WaitForSeconds(delayTime);
float startTime = 0f;
while(true)
{
startTime += Time.DeltaTime;
player.transform.position = Vector3.Lerp(player.transform.position, newPosition, startTime);
// once player is at newPosition, stop the Coroutine
if (player.transform.position == newPosition)
{
yield break;
}
// else keep Lerping toward newPosition
yield return null;
}
}
Lerp works like this, top level wise. You provide two Vector3's and a Float. The first Vector3 is the current Position, while the second is the Target Position. The final argument Float is a fraction used to determine the returned Vector3, the new Position. If the Float is 0, the first Vector3 is return ie no movement, if the Float is 1, the second Vector3 is return ie movement complete. If the Float is 0 > && > 1, that value is used to select a point between the two Vector3s toward the second one. Smoothing is often needed to get rid of gittering, or quick skips in the movement.
Docs on Lerp: https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html
Wiki that talks above moving objects: http://wiki.unity3d.com/index.php?title=MoveObject
Your answer
![](https://koobas.hobune.stream/wayback/20220612094407im_/https://answers.unity.com/themes/thub/images/avi.jpg)