Hi,
I’m new to unity and i’m trying to develop a small game which resembles to Subway Surfers. It’s an endless runner in which when player collides with an Obstacle the enemy chasing him comes into scene
and when player uses his power the enemy needs to move back.
i.e., when player collides with some obstacle enemy comes into camera scope or else he’ll be following player outside of camera scope.
I have made enemy a child object of player and i also took two empty gameobjects as start and end position for enemy and made them child objects of player.
now when player moves forward enemy and his start and end positions also move with him
now what i need is when player collides with any obstacle the enemy should move from start position to his end position and when player uses his power enemy should then move form end position
to start position
to implement this i have written two scripts one for player to move and know the collision with obstacle
and the second one is on enemy to lerp him from start to end position but the result was not right
i have also tried vector3.forward i’m also adding the codes that i have tried
Here are some other codes which i have tried any help would be appreciated thanks in advance