Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public GameObject player;
- float offsetX = 0;
- float offsetZ = -15;
- float maximumDistance = 5;
- float playerVelocity = 10;
- float movementX;
- float movementZ;
- // Update is called once per frame
- void Update (){
- movementX = ((player.transform.position.x + offsetX - this.transform.position.x))/maximumDistance;
- movementZ = ((player.transform.position.z + offsetZ - this.transform.position.z))/maximumDistance;
- this.transform.position += new Vector3((movementX * playerVelocity * Time.deltaTime), 0, (movementZ * playerVelocity * Time.deltaTime));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement