Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Solved] Player controller rotation

Discussion in 'Scripting' started by malak, Nov 15, 2018.

  1. malak

    malak

    Joined:
    Jan 23, 2014
    Posts:
    65
    hey everybody ,

    i have a little trouble in a script i can't solve :(

    i want my character move where i look but with this script it rotate my character where i look but for some raison i dont want rotate my character (i'm working on VR and rotation broke the gameplay).

    i just need a simple script who move where i look but dont rotate .
    here is the script i use who rotate my character :
    Code (CSharp):
    1.  
    2.  
    3. using System;
    4. using UnityEngine;
    5.  
    6. /// <summary>
    7. /// Controls the player's movement in virtual reality.
    8. /// </summary>
    9. [RequireComponent(typeof(CharacterController))]
    10. public class OVRPlayerController : MonoBehaviour
    11. {
    12.     /// <summary>
    13.     /// The rate acceleration during movement.
    14.     /// </summary>
    15.     public float Acceleration = 0.1f;
    16.  
    17.     /// <summary>
    18.     /// The rate of damping on movement.
    19.     /// </summary>
    20.     public float Damping = 0.3f;
    21.  
    22.     /// <summary>
    23.     /// The rate of additional damping when moving sideways or backwards.
    24.     /// </summary>
    25.     public float BackAndSideDampen = 0.5f;
    26.  
    27.     /// <summary>
    28.     /// The force applied to the character when jumping.
    29.     /// </summary>
    30.     public float JumpForce = 0.3f;
    31.  
    32.     /// <summary>
    33.     /// The rate of rotation when using a gamepad.
    34.     /// </summary>
    35.     public float RotationAmount = 1.5f;
    36.  
    37.     /// <summary>
    38.     /// The rate of rotation when using the keyboard.
    39.     /// </summary>
    40.     public float RotationRatchet = 45.0f;
    41.  
    42.     /// <summary>
    43.     /// The player will rotate in fixed steps if Snap Rotation is enabled.
    44.     /// </summary>
    45.     [Tooltip("The player will rotate in fixed steps if Snap Rotation is enabled.")]
    46.     public bool SnapRotation = true;
    47.  
    48.     /// <summary>
    49.     /// How many fixed speeds to use with linear movement? 0=linear control
    50.     /// </summary>
    51.     [Tooltip("How many fixed speeds to use with linear movement? 0=linear control")]
    52.     public int FixedSpeedSteps;
    53.  
    54.     /// <summary>
    55.     /// If true, reset the initial yaw of the player controller when the Hmd pose is recentered.
    56.     /// </summary>
    57.     public bool HmdResetsY = true;
    58.  
    59.     /// <summary>
    60.     /// If true, tracking data from a child OVRCameraRig will update the direction of movement.
    61.     /// </summary>
    62.     public bool HmdRotatesY = true;
    63.  
    64.     /// <summary>
    65.     /// Modifies the strength of gravity.
    66.     /// </summary>
    67.     public float GravityModifier = 0.379f;
    68.    
    69.     /// <summary>
    70.     /// If true, each OVRPlayerController will use the player's physical height.
    71.     /// </summary>
    72.     public bool useProfileData = true;
    73.  
    74.     /// <summary>
    75.     /// The CameraHeight is the actual height of the HMD and can be used to adjust the height of the character controller, which will affect the
    76.     /// ability of the character to move into areas with a low ceiling.
    77.     /// </summary>
    78.     [NonSerialized]
    79.     public float CameraHeight;
    80.  
    81.     /// <summary>
    82.     /// This event is raised after the character controller is moved. This is used by the OVRAvatarLocomotion script to keep the avatar transform synchronized
    83.     /// with the OVRPlayerController.
    84.     /// </summary>
    85.     public event Action<Transform> TransformUpdated;
    86.  
    87.     /// <summary>
    88.     /// This bool is set to true whenever the player controller has been teleported. It is reset after every frame. Some systems, such as
    89.     /// CharacterCameraConstraint, test this boolean in order to disable logic that moves the character controller immediately
    90.     /// following the teleport.
    91.     /// </summary>
    92.     [NonSerialized] // This doesn't need to be visible in the inspector.
    93.     public bool Teleported;
    94.  
    95.     /// <summary>
    96.     /// This event is raised immediately after the camera transform has been updated, but before movement is updated.
    97.     /// </summary>
    98.     public event Action CameraUpdated;
    99.  
    100.     /// <summary>
    101.     /// This event is raised right before the character controller is actually moved in order to provide other systems the opportunity to
    102.     /// move the character controller in response to things other than user input, such as movement of the HMD. See CharacterCameraConstraint.cs
    103.     /// for an example of this.
    104.     /// </summary>
    105.     public event Action PreCharacterMove;
    106.  
    107.     /// <summary>
    108.     /// When true, user input will be applied to linear movement. Set this to false whenever the player controller needs to ignore input for
    109.     /// linear movement.
    110.     /// </summary>
    111.     public bool EnableLinearMovement = true;
    112.  
    113.     /// <summary>
    114.     /// When true, user input will be applied to rotation. Set this to false whenever the player controller needs to ignore input for rotation.
    115.     /// </summary>
    116.     public bool EnableRotation = true;
    117.  
    118.     protected CharacterController Controller = null;
    119.     protected OVRCameraRig CameraRig = null;
    120.  
    121.     private float MoveScale = 1.0f;
    122.     private Vector3 MoveThrottle = Vector3.zero;
    123.     private float FallSpeed = 0.0f;
    124.     private OVRPose? InitialPose;
    125.     public float InitialYRotation { get; private set; }
    126.     private float MoveScaleMultiplier = 1.0f;
    127.     private float RotationScaleMultiplier = 1.0f;
    128.     private bool  SkipMouseRotation = true; // It is rare to want to use mouse movement in VR, so ignore the mouse by default.
    129.     private bool  HaltUpdateMovement = false;
    130.     private bool prevHatLeft = false;
    131.     private bool prevHatRight = false;
    132.     private float SimulationRate = 60f;
    133.     private float buttonRotation = 0f;
    134.     private bool ReadyToSnapTurn; // Set to true when a snap turn has occurred, code requires one frame of centered thumbstick to enable another snap turn.
    135.  
    136.     void Start()
    137.     {
    138.         // Add eye-depth as a camera offset from the player controller
    139.         var p = CameraRig.transform.localPosition;
    140.         p.z = OVRManager.profile.eyeDepth;
    141.         CameraRig.transform.localPosition = p;
    142.         UnityEngine.XR.InputTracking.Recenter();
    143.     }
    144.  
    145.     void Awake()
    146.     {
    147.         Controller = gameObject.GetComponent<CharacterController>();
    148.  
    149.         if(Controller == null)
    150.             Debug.LogWarning("OVRPlayerController: No CharacterController attached.");
    151.  
    152.         // We use OVRCameraRig to set rotations to cameras,
    153.         // and to be influenced by rotation
    154.         OVRCameraRig[] CameraRigs = gameObject.GetComponentsInChildren<OVRCameraRig>();
    155.  
    156.         if(CameraRigs.Length == 0)
    157.             Debug.LogWarning("OVRPlayerController: No OVRCameraRig attached.");
    158.         else if (CameraRigs.Length > 1)
    159.             Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraRig attached.");
    160.         else
    161.             CameraRig = CameraRigs[0];
    162.  
    163.         InitialYRotation = transform.rotation.eulerAngles.y;
    164.     }
    165.  
    166.     void OnEnable()
    167.     {
    168.         OVRManager.display.RecenteredPose += ResetOrientation;
    169.  
    170.         if (CameraRig != null)
    171.         {
    172.             CameraRig.UpdatedAnchors += UpdateTransform;
    173.         }
    174.     }
    175.  
    176.     void OnDisable()
    177.     {
    178.         OVRManager.display.RecenteredPose -= ResetOrientation;
    179.  
    180.         if (CameraRig != null)
    181.         {
    182.             CameraRig.UpdatedAnchors -= UpdateTransform;
    183.         }
    184.     }
    185.  
    186.     void Update()
    187.     {
    188.         //Use keys to ratchet rotation
    189.         if (Input.GetKeyDown(KeyCode.Q))
    190.             buttonRotation -= RotationRatchet;
    191.  
    192.         if (Input.GetKeyDown(KeyCode.E))
    193.             buttonRotation += RotationRatchet;
    194.     }
    195.  
    196.     protected virtual void UpdateController()
    197.     {
    198.         if (useProfileData)
    199.         {
    200.             if (InitialPose == null)
    201.             {
    202.                 // Save the initial pose so it can be recovered if useProfileData
    203.                 // is turned off later.
    204.                 InitialPose = new OVRPose()
    205.                 {
    206.                     position = CameraRig.transform.localPosition,
    207.                     orientation = CameraRig.transform.localRotation
    208.                 };
    209.             }
    210.  
    211.             var p = CameraRig.transform.localPosition;
    212.             if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
    213.             {
    214.                 p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
    215.             }
    216.             else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
    217.             {
    218.                 p.y = - (0.5f * Controller.height) + Controller.center.y;
    219.             }
    220.             CameraRig.transform.localPosition = p;
    221.         }
    222.         else if (InitialPose != null)
    223.         {
    224.             // Return to the initial pose if useProfileData was turned off at runtime
    225.             CameraRig.transform.localPosition = InitialPose.Value.position;
    226.             CameraRig.transform.localRotation = InitialPose.Value.orientation;
    227.             InitialPose = null;
    228.         }
    229.  
    230.         CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;
    231.  
    232.         if (CameraUpdated != null)
    233.         {
    234.             CameraUpdated();
    235.         }
    236.  
    237.         UpdateMovement();
    238.  
    239.         Vector3 moveDirection = Vector3.zero;
    240.  
    241.         float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));
    242.  
    243.         MoveThrottle.x /= motorDamp;
    244.         MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
    245.         MoveThrottle.z /= motorDamp;
    246.  
    247.         moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;
    248.  
    249.         // Gravity
    250.         if (Controller.isGrounded && FallSpeed <= 0)
    251.             FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
    252.         else
    253.             FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
    254.  
    255.         moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;
    256.  
    257.  
    258.         if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
    259.         {
    260.             // Offset correction for uneven ground
    261.             float bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
    262.             moveDirection -= bumpUpOffset * Vector3.up;
    263.         }
    264.  
    265.         if (PreCharacterMove != null)
    266.         {
    267.             PreCharacterMove();
    268.             Teleported = false;
    269.         }
    270.  
    271.         Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));
    272.  
    273.         // Move contoller
    274.         Controller.Move(moveDirection);
    275.         Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));
    276.  
    277.         if (predictedXZ != actualXZ)
    278.             MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
    279.     }
    280.  
    281.  
    282.  
    283.  
    284.  
    285.     public virtual void UpdateMovement()
    286.     {
    287.         if (HaltUpdateMovement)
    288.             return;
    289.  
    290.         if (EnableLinearMovement)
    291.         {
    292.             bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
    293.             bool moveLeft = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow);
    294.             bool moveRight = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow);
    295.             bool moveBack = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
    296.  
    297.             bool dpad_move = false;
    298.  
    299.             if (OVRInput.Get(OVRInput.Button.DpadUp))
    300.             {
    301.                 moveForward = true;
    302.                 dpad_move = true;
    303.  
    304.             }
    305.  
    306.             if (OVRInput.Get(OVRInput.Button.DpadDown))
    307.             {
    308.                 moveBack = true;
    309.                 dpad_move = true;
    310.             }
    311.  
    312.             MoveScale = 1.0f;
    313.  
    314.             if ((moveForward && moveLeft) || (moveForward && moveRight) ||
    315.                 (moveBack && moveLeft) || (moveBack && moveRight))
    316.                 MoveScale = 0.70710678f;
    317.  
    318.             // No positional movement if we are in the air
    319.             if (!Controller.isGrounded)
    320.                 MoveScale = 0.0f;
    321.  
    322.             MoveScale *= SimulationRate * Time.deltaTime;
    323.  
    324.             // Compute this for key movement
    325.             float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
    326.  
    327.             // Run!
    328.             if (dpad_move || Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
    329.                 moveInfluence *= 2.0f;
    330.  
    331.             Quaternion ort = transform.rotation;
    332.             Vector3 ortEuler = ort.eulerAngles;
    333.             ortEuler.z = ortEuler.x = 0f;
    334.             ort = Quaternion.Euler(ortEuler);
    335.  
    336.             if (moveForward)
    337.                 MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward);
    338.             if (moveBack)
    339.                 MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back);
    340.             if (moveLeft)
    341.                 MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left);
    342.             if (moveRight)
    343.                 MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right);
    344.  
    345.  
    346.  
    347.             moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
    348.  
    349. #if !UNITY_ANDROID // LeftTrigger not avail on Android game pad
    350.             moveInfluence *= 1.0f + OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);
    351. #endif
    352.  
    353.             Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
    354.  
    355.             // If speed quantization is enabled, adjust the input to the number of fixed speed steps.
    356.             if (FixedSpeedSteps > 0)
    357.             {
    358.                 primaryAxis.y = Mathf.Round(primaryAxis.y * FixedSpeedSteps) / FixedSpeedSteps;
    359.                 primaryAxis.x = Mathf.Round(primaryAxis.x * FixedSpeedSteps) / FixedSpeedSteps;
    360.             }
    361.  
    362.             if (primaryAxis.y > 0.0f)
    363.                 MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.z * moveInfluence * Vector3.forward);
    364.  
    365.             if (primaryAxis.y < 0.0f)
    366.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.z * moveInfluence *
    367.                                        BackAndSideDampen * Vector3.back);
    368.  
    369.             if (primaryAxis.x < 0.0f)
    370.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.x) * transform.lossyScale.x * moveInfluence *
    371.                                        BackAndSideDampen * Vector3.left);
    372.  
    373.             if (primaryAxis.x > 0.0f)
    374.                 MoveThrottle += ort * (primaryAxis.x * transform.lossyScale.x * moveInfluence * BackAndSideDampen *
    375.                                        Vector3.right);
    376.         }
    377.  
    378.         if (EnableRotation)
    379.         {
    380.             Vector3 euler = transform.rotation.eulerAngles;
    381.             float rotateInfluence = SimulationRate * Time.deltaTime * RotationAmount * RotationScaleMultiplier;
    382.  
    383.             bool curHatLeft = OVRInput.Get(OVRInput.Button.PrimaryShoulder);
    384.  
    385.             if (curHatLeft && !prevHatLeft)
    386.                 euler.y -= RotationRatchet;
    387.  
    388.             prevHatLeft = curHatLeft;
    389.  
    390.             bool curHatRight = OVRInput.Get(OVRInput.Button.SecondaryShoulder);
    391.  
    392.             if (curHatRight && !prevHatRight)
    393.                 euler.y += RotationRatchet;
    394.  
    395.             prevHatRight = curHatRight;
    396.  
    397.             euler.y += buttonRotation;
    398.             buttonRotation = 0f;
    399.  
    400.  
    401. #if !UNITY_ANDROID || UNITY_EDITOR
    402.             if (!SkipMouseRotation)
    403.                 euler.y += Input.GetAxis("Mouse X") * rotateInfluence * 3.25f;
    404. #endif
    405.  
    406.             if (SnapRotation)
    407.             {
    408.  
    409.                 if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickLeft))
    410.                 {
    411.                     if (ReadyToSnapTurn)
    412.                     {
    413.                         euler.y -= RotationRatchet;
    414.                         ReadyToSnapTurn = false;
    415.                     }
    416.                 }
    417.                 else if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight))
    418.                 {
    419.                     if (ReadyToSnapTurn)
    420.                     {
    421.                         euler.y += RotationRatchet;
    422.                         ReadyToSnapTurn = false;
    423.                     }
    424.                 }
    425.                 else
    426.                 {
    427.                     ReadyToSnapTurn = true;
    428.                 }
    429.             }
    430.             else
    431.             {
    432.                 Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
    433.                 euler.y += secondaryAxis.x * rotateInfluence;
    434.             }
    435.  
    436.             transform.rotation = Quaternion.Euler(euler);
    437.         }
    438.     }
    439.  
    440.  
    441.     /// <summary>
    442.     /// Invoked by OVRCameraRig's UpdatedAnchors callback. Allows the Hmd rotation to update the facing direction of the player.
    443.     /// </summary>
    444.     public void UpdateTransform(OVRCameraRig rig)
    445.     {
    446.         Transform root = CameraRig.trackingSpace;
    447.         Transform centerEye = CameraRig.centerEyeAnchor;
    448.  
    449.         if (HmdRotatesY && !Teleported)
    450.         {
    451.             Vector3 prevPos = root.position;
    452.             Quaternion prevRot = root.rotation;
    453.  
    454.             transform.rotation = Quaternion.Euler(0.0f, centerEye.rotation.eulerAngles.y, 0.0f);
    455.  
    456.             root.position = prevPos;
    457.             root.rotation = prevRot;
    458.         }
    459.  
    460.         UpdateController();
    461.         if (TransformUpdated != null)
    462.         {
    463.             TransformUpdated(root);
    464.         }
    465.     }
    466.  
    467.     /// <summary>
    468.     /// Jump! Must be enabled manually.
    469.     /// </summary>
    470.     public bool Jump()
    471.     {
    472.         if (!Controller.isGrounded)
    473.             return false;
    474.  
    475.         MoveThrottle += new Vector3(0, transform.lossyScale.y * JumpForce, 0);
    476.  
    477.         return true;
    478.     }
    479.  
    480.     /// <summary>
    481.     /// Stop this instance.
    482.     /// </summary>
    483.     public void Stop()
    484.     {
    485.         Controller.Move(Vector3.zero);
    486.         MoveThrottle = Vector3.zero;
    487.         FallSpeed = 0.0f;
    488.     }
    489.  
    490.     /// <summary>
    491.     /// Gets the move scale multiplier.
    492.     /// </summary>
    493.     /// <param name="moveScaleMultiplier">Move scale multiplier.</param>
    494.     public void GetMoveScaleMultiplier(ref float moveScaleMultiplier)
    495.     {
    496.         moveScaleMultiplier = MoveScaleMultiplier;
    497.     }
    498.  
    499.     /// <summary>
    500.     /// Sets the move scale multiplier.
    501.     /// </summary>
    502.     /// <param name="moveScaleMultiplier">Move scale multiplier.</param>
    503.     public void SetMoveScaleMultiplier(float moveScaleMultiplier)
    504.     {
    505.         MoveScaleMultiplier = moveScaleMultiplier;
    506.     }
    507.  
    508.     /// <summary>
    509.     /// Gets the rotation scale multiplier.
    510.     /// </summary>
    511.     /// <param name="rotationScaleMultiplier">Rotation scale multiplier.</param>
    512.     public void GetRotationScaleMultiplier(ref float rotationScaleMultiplier)
    513.     {
    514.         rotationScaleMultiplier = RotationScaleMultiplier;
    515.     }
    516.  
    517.     /// <summary>
    518.     /// Sets the rotation scale multiplier.
    519.     /// </summary>
    520.     /// <param name="rotationScaleMultiplier">Rotation scale multiplier.</param>
    521.     public void SetRotationScaleMultiplier(float rotationScaleMultiplier)
    522.     {
    523.         RotationScaleMultiplier = rotationScaleMultiplier;
    524.     }
    525.  
    526.     /// <summary>
    527.     /// Gets the allow mouse rotation.
    528.     /// </summary>
    529.     /// <param name="skipMouseRotation">Allow mouse rotation.</param>
    530.     public void GetSkipMouseRotation(ref bool skipMouseRotation)
    531.     {
    532.         skipMouseRotation = SkipMouseRotation;
    533.     }
    534.  
    535.     /// <summary>
    536.     /// Sets the allow mouse rotation.
    537.     /// </summary>
    538.     /// <param name="skipMouseRotation">If set to <c>true</c> allow mouse rotation.</param>
    539.     public void SetSkipMouseRotation(bool skipMouseRotation)
    540.     {
    541.         SkipMouseRotation = skipMouseRotation;
    542.     }
    543.  
    544.     /// <summary>
    545.     /// Gets the halt update movement.
    546.     /// </summary>
    547.     /// <param name="haltUpdateMovement">Halt update movement.</param>
    548.     public void GetHaltUpdateMovement(ref bool haltUpdateMovement)
    549.     {
    550.         haltUpdateMovement = HaltUpdateMovement;
    551.     }
    552.  
    553.     /// <summary>
    554.     /// Sets the halt update movement.
    555.     /// </summary>
    556.     /// <param name="haltUpdateMovement">If set to <c>true</c> halt update movement.</param>
    557.     public void SetHaltUpdateMovement(bool haltUpdateMovement)
    558.     {
    559.         HaltUpdateMovement = haltUpdateMovement;
    560.     }
    561.  
    562.     /// <summary>
    563.     /// Resets the player look rotation when the device orientation is reset.
    564.     /// </summary>
    565.     public void ResetOrientation()
    566.     {
    567.         if (HmdResetsY && !HmdRotatesY)
    568.         {
    569.             Vector3 euler = transform.rotation.eulerAngles;
    570.             euler.y = InitialYRotation;
    571.             transform.rotation = Quaternion.Euler(euler);
    572.         }
    573.     }
    574. }
    575.  
    576.  
    i hope you understand what i mean and sorry for my bad english i'm french ;)
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,584
    Don't just copy scrip which you don't understand. At least try to study it, or debug.
    Start from something simple. Look up tutorials.
     
  3. malak

    malak

    Joined:
    Jan 23, 2014
    Posts:
    65
    yeah that's why i'm here and ask for help because i don't find a way to solve my problem , i can solve it by puting this script on cube and make my character follow him ;)
    but i want do something simple and clearely .

    if you want explain me why it rotate and not just take the direction your welcome my friend ;)
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,584
    There is near 500 lines of script with comments.
    Sorry but I am not going to analyse how this works.
    Will be meaningless to guide, if is not your script.

    If you really want to use it, I suggest strip id down, reverse engineer, use Debug.Log (), Step Debug, or any of these combinations.

    Other option, is to ask / wait for someone else to popup to assist you.

    And of course, best option for you, is to build a prototype, from working cube as you have tat part done, as you saying.
    All best.
     
  5. malak

    malak

    Joined:
    Jan 23, 2014
    Posts:
    65
    I find a way for people who looking for solution ;)

    add empty object in your character and set the script rotate the empty object and make your character move in the rotation of your empty gameObject ;)

    That's it , enjoy ;)
     
    poz_unity likes this.