Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour
  6. {
  7.     public GameObject followerGO;
  8.     Vector3 actualFutePos;
  9.     Quaternion actualFuteRot;
  10.     public float futeRotYMin;
  11.     public float futeRotYMax;
  12.     bool hasFinishedRotating;
  13.     Vector3 downFutePos;
  14.  
  15.  
  16.  
  17.  
  18.     // Start is called before the first frame update
  19.     void Start()
  20.     {
  21.         transform.position = followerGO.transform.position;
  22.         actualFutePos.y = followerGO.transform.position.y;
  23.     }
  24.  
  25.     // Update is called once per frame
  26.     void Update()
  27.     {
  28.  
  29.         actualFutePos.x = followerGO.transform.position. x;
  30.         actualFutePos.z = followerGO.transform.position.z;
  31.         actualFuteRot.y = followerGO.transform.rotation.y;
  32.         actualFuteRot.z = followerGO.transform.rotation.z;
  33.         actualFuteRot.w = followerGO.transform.rotation.w;
  34.        
  35.         //transform.position;
  36.         if (Input.GetMouseButton(0))
  37.         {
  38.             actualFutePos.y += transform.up.y * -1*Time.deltaTime;
  39.             transform.position = actualFutePos;
  40.            
  41.             Vector3 direction =transform.position-actualFutePos;
  42.             Debug.DrawRay(transform.position, direction, Color.red);
  43.            
  44.             hasFinishedRotating = false;
  45.             Vector3 direction1 = -transform.forward*3;
  46.            
  47.         }
  48.         else
  49.         {
  50.            
  51.            if(transform.position.y<=5.13)
  52.             {
  53.                
  54.                     actualFutePos.y += transform.up.y * 1*Time.deltaTime;
  55.  
  56.                 Vector3 direction = transform.position - actualFutePos;
  57.                 Debug.DrawRay(transform.position, direction, Color.red);
  58.                 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(-direction), 20.1f * Time.deltaTime);
  59.                 actualFuteRot = transform.rotation;
  60.             }
  61.          
  62.             else if(transform.rotation.x!=0)
  63.             {
  64.                 transform.rotation = Quaternion.Slerp(transform.rotation, actualFuteRot, 30.50f*Time.deltaTime);
  65.             }
  66.             else
  67.             {
  68.                 transform.rotation = Quaternion.Slerp(transform.rotation, actualFuteRot, 30.50f * Time.deltaTime);
  69.             }
  70.  
  71.            
  72.         }
  73.  
  74.  
  75.         transform.position = actualFutePos;
  76.         transform.rotation = followerGO.transform.rotation;
  77.  
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement