Question by
mattfasullo · May 03, 2020 at 01:32 AM ·
c#unity 5vector3transform.positionlocalposition
Trying to transform my character's local position on a GetKey.
So I'm trying to make my character move back a few meters when I press space, but for some reason he keeps teleporting to a very specific spot in the game space, not even based on his local position (or so it seems).
currentPosition = new Vector3(transform.localPosition.x, transform.localPosition.y);
if (transform.localScale == new Vector3(3.161757f, 3.161757f, transform.localScale.z) && Input.GetKeyDown(KeyCode.Space)) //facing left
{
transform.localPosition = currentPosition * dashFactor * Time.deltaTime;
animator.Play("PlayerDash");
}
I cannot for the life of me figure out why this isn't working. I'm very new to code, so I have a lot to learn. But from my understanding, this should work, no? There's obviously some kind of step I'm missing, and I would love to learn. Thanks guys :)
Comment