Answers for "Vector2.SmoothDamp"

0

Vector2.SmoothDamp

using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour {
    public Transform target;
    public float smoothTime = 0.3F;
    private float yVelocity = 0.0F;
    void Update() {
        float newPosition = Mathf.SmoothDamp(transform.position.y, target.position.y, ref yVelocity, smoothTime);
        transform.position = new Vector3(transform.position.x, newPosition, transform.position.z);
    }
}
Posted by: Guest on July-13-2021

Browse Popular Code Answers by Language