So im trying to get my player character to move forwards and backwards when W and S are pressed, but for some reason when i try to move forwards and backwards it keeps moving me back to a set position where i landed? not sure if something is overriding the movement code in the standing code maybe? but i cant find anything. any help is appreciated. Movement code: https://paste.ofcode.org/pHJnHpecdwF9MB2qr56Hgz Standing code: https://paste.ofcode.org/PxBhAQYvjKn2W4YmJq3C27
EDIT: My quick glance was incorrect.
I do however notice, that you have no moveSpeed, so the amount of motion is very very trivial.
I just now, created a cube, and dropped this script on it. it moves forward , and back just fine.
private float moveSpeed = 5.0f;
private void Update()
{
if (Input.GetKey(KeyCode.W)) transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
else if (Input.GetKey(KeyCode.S)) transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
}
Also, im not sure you are actually executing the unity method Update(); with an Update() spelt update()…
protected override void update()
What’s in your BirdController script? Your MovementManager script works fine if isStandingBool is set to true. isStandingBool is not mentioned anywhere in your BirdState script.
Also, something unrelated that you may want to consider is if you move something with transform.Translate it will not collide with things but instead go through them.
Edit: Also just noticed that in your BirdState script you’ve got this in update:
ctrlRef.transform.position = Vector3.Lerp(ctrlRef.transform.position, target + ctrlRef.Profile.StandingYOffset * targetUp, lerpToTarget);
That could potentially be the source of your issue. I have no idea what ctrlRef is.