So…It seems like I’m not having any luck getting any answers, so I’m posting this here. Hopefully I’m asking the right questions. btw, I’m new to scripting/programming, so this whole thing feels like a nightmare atm, but I’m moving forward
So, I’m trying to figure out how to have an object move relative to another object, but from its own original position in the scene…I can do this by parenting, but I want the object to move half as much as the second object. Here’s a simple code:
public Transform obj2;
void Update()
{
Vector3 newPosition = new Vector3(
obj2.transform.position.x * .5f,
obj2.transform.position.y * .5f,
obj2.transform.position.z * .5f);
transform.position = newPosition;
}
This code does some of what I’m trying to do, but I want the same behavior from the main object’s current position… so that when I press play, it doesn’t pop the main object to .5*position of object2, but just moves .5 as much when object2 moves… I hope this makes sense. I don’t seem to be getting the right answers so if this doesn’t make full sense please let me know. Thanks