Question by
SGT_Smith · Apr 04, 2016 at 07:25 AM ·
c#distancetime.deltatimeforward
Move player distance forward over time.
Hi, i'm trying to move the player one step forward over time during his swing attack. I'm not using root motion so it needs to be done through code.
The way I figure it right now, I need to use IEnumerator, and while the player isnt at the new position move it forward by delta time. What I'm having trouble with is how to get a new position thas a certain distance FORWARD from the direction the player is facing.
Mock to get an idea of what i'd like to do:
IEnumerator(float distance) {
Vector3 currentPos;
Vector3 newPos;
if (transform.position != newPos) {
transform.position += transform.forward * Time.deltaTime;
yield return null;
}
else {
yield break;
}
Comment