Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- public GameObject followerGO;
- Vector3 actualFutePos;
- Quaternion actualFuteRot;
- public float futeRotYMin;
- public float futeRotYMax;
- bool hasFinishedRotating;
- Vector3 downFutePos;
- // Start is called before the first frame update
- void Start()
- {
- transform.position = followerGO.transform.position;
- actualFutePos.y = followerGO.transform.position.y;
- }
- // Update is called once per frame
- void Update()
- {
- actualFutePos.x = followerGO.transform.position. x;
- actualFutePos.z = followerGO.transform.position.z;
- actualFuteRot.y = followerGO.transform.rotation.y;
- actualFuteRot.z = followerGO.transform.rotation.z;
- actualFuteRot.w = followerGO.transform.rotation.w;
- //transform.position;
- if (Input.GetMouseButton(0))
- {
- actualFutePos.y += transform.up.y * -1*Time.deltaTime;
- transform.position = actualFutePos;
- Vector3 direction =transform.position-actualFutePos;
- Debug.DrawRay(transform.position, direction, Color.red);
- hasFinishedRotating = false;
- Vector3 direction1 = -transform.forward*3;
- }
- else
- {
- if(transform.position.y<=5.13)
- {
- actualFutePos.y += transform.up.y * 1*Time.deltaTime;
- Vector3 direction = transform.position - actualFutePos;
- Debug.DrawRay(transform.position, direction, Color.red);
- transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(-direction), 20.1f * Time.deltaTime);
- actualFuteRot = transform.rotation;
- }
- else if(transform.rotation.x!=0)
- {
- transform.rotation = Quaternion.Slerp(transform.rotation, actualFuteRot, 30.50f*Time.deltaTime);
- }
- else
- {
- transform.rotation = Quaternion.Slerp(transform.rotation, actualFuteRot, 30.50f * Time.deltaTime);
- }
- }
- transform.position = actualFutePos;
- transform.rotation = followerGO.transform.rotation;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement