Question by 
               USJackal · Nov 28, 2017 at 05:19 PM · 
                vrcharactercontrollermovement script  
              
 
              Drunk Walk VR Simulation,Drunk VR Simulation
Hi! I'm currently working on a project that is going to be a Drunk Obstacle course in VR, and I have hit a roadblock.
I wanted to simulate loss of motor controls by making the character swerve left and right whilst moving forward with an autowalk feature. What I have so far is this.
  using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     
     public class VrLookWalk : MonoBehaviour {
         public Transform vrCamera;
         public float toggleAngle = 30.0f;
     
         public float speed = 3.0f;
         private float thrust = 2f;
         public bool moveforward;
         public bool swayLeftBool;
         public bool swayRightBool;
     
     
         private CharacterController cc;
     
         // Use this for initialization
         void Start () {
     
             swayLeftBool = true;
             cc = GetComponent<CharacterController>();
      
     
             
         }
         
         // Update is called once per frame
         void Update () {
     
             if ( vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f) {
                 moveforward = true;
             }
             else
             {
                 moveforward = false;
             }
             if (moveforward)
             {
                 Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
     
                 Invoke("swayDirection", 3f);
                 cc.SimpleMove(forward * speed);
     
                 if (swayLeftBool == true){
                     swayLeft();
                 }
                 else if(swayRightBool == true)
                 { swayRight(); }
             }
         }
     
         void swayDirection()
         {
             if (swayLeftBool == true)
             { swayRightBool = true; swayLeftBool = false; }
             else if(swayRightBool == true)
             { swayLeftBool = true; swayRightBool = false; }
             
         }
     
         void swayLeft()
         { cc.SimpleMove(transform.right *- thrust); }
         
         void swayRight()
         { cc.SimpleMove(transform.right * thrust);}
     }
     
 
               But this results in some jittery movement that does not at all seem to have a pattern. If anyone can tell me how to possibly impliment the Sin method correctly, that would be much appreciated.
               Comment
              
 
               
              Your answer