// Update is called once per frame void Update() { float horizontal = Input.GetAxis("Horizontal") * horizontalOffsetStrength; horizontal = Mathf.Clamp(horizontal, -horizontalOffsetClamp, horizontalOffsetClamp); curveDist = curvePlayer.position2D.x + horizontal; Vector3 targetPos = curvePath.GetPointAtDistance(ref curveDist, 0); transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref refPos, FollowSpeed); Quaternion toRot = curvePath.GetRotationAtDistance(ref curveDist, 0); transform.rotation = Quaternion.Slerp(transform.rotation, Target.rotation, RotateSpeed * Time.deltaTime); }
// Start is called before the first frame update void Start() { mAnimator = GetComponentInChildren <Animator>(); lastCurvePosY = curve.GetPointAtDistance(ref position2D.x, currentPathIndex).y; rb = GetComponent <Rigidbody>(); }