init
This commit is contained in:
commit
862afc9b7a
478 changed files with 197737 additions and 0 deletions
25
Assets/Scripts/FollowObject.cs
Normal file
25
Assets/Scripts/FollowObject.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FollowObject : MonoBehaviour
|
||||
{
|
||||
public Transform follow;
|
||||
public Vector2 xPosLimit;
|
||||
public float smoothiness;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 pos = transform.position;
|
||||
pos -= (transform.position - follow.position) * smoothiness * Time.deltaTime;
|
||||
pos.x = Mathf.Clamp(pos.x, xPosLimit.x, xPosLimit.y);
|
||||
pos.z = transform.position.z;
|
||||
transform.position = pos;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue