I’ve googled this over and over again and can’t find the solution. So I have a little character follow the player around like Navi from Zelda. I code the follower in the parent’s control code by declaring the follower object and its transform and use this to move it:
void Seed()
{
//SEED MOVEMENT
Vector3 seedPos = new Vector3(0, 0, 0); //Initialize seedPos
seedTimer += Time.deltaTime; //Increase seed movement timer over time
if (seedTimer > seedMove) //If seed timer is at the end length of time
{
seedXTo = Random.Range(-1.5f, 1.5f); //Set x position of seed to move towards
seedYTo = Random.Range(0.5f, 1.5f); //Set y position of seed to move towards
seedTimer = 0; //Resets the seed movement timer
}
seedPos = new Vector3(seedXTo, seedYTo, 0); //Places new x and y position into a Vector3
seedTrans.position = Vector3.Lerp(seedTrans.position, seedPos, 3 * Time.deltaTime); //Smoothly move towards x and y position
}
No matter what I do, when I change direction with the player (When I change direction I code it’s localScale to be -1 when moving left and 1 when moving right) and when I do it multiplies the x value of the parent scale by the childs x transform, so when I change direction it jerks to it’s negative x and moves toward the seedXTo and seedYTo. I’ve tried Mathf.Abs, localPosition vs position and nothing works. Help!