So… this is another very newbie programming question. I’m trying to set the position.y of a gameobject to equal to transform.position.y + x, x being a float number that changes based on the speed of a different gameobject in the scene. the basic problem is that it seems like whatever I do, adding a number to the transform.position.y in update will add it every frame… my question is how can I add a number to a position axis of an object that doesn’t add, but updates the addition value of the position.y+x… I hope this makes sense… here’s my epic fail code so far:
void Update()
{
transform.position = new Vector3(transform.position.x, test(), transform.position.z);
}
float test()
{
float newPos = transform.position.x + speed;
return newPos;
}