- Home /
Rotate player 360 degrees once
Hello everyone!
I'm making a simple fps game and I have a problem. I want the player to spin around 360 degrees ONCE and shoot (please don't ask why). Now, I have this short script that creates the bullet and plays the gunshot sound. I found some tutorials and I modified it a bit. Here it is:
  var prefabBullet:Transform;
     var Spawnpoint:Transform;
     var shootForce:float;
     var shootSound: AudioClip;
     private var startRotY: float = 0; 
     private var endRotY: float = 0; 
     var currentRotY: float;
     
     function Update()
     {
         if(Input.GetButtonDown("Fire1"))
         {
             currentRotY = 0;
             startRotY = 0;
             endRotY = 360;
             transform.rotation = Quaternion.Euler(0,0 ,0);
             var instanceBullet = Instantiate(prefabBullet, Spawnpoint.transform.position, Spawnpoint.transform.rotation);
             instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
             audio.PlayOneShot(shootSound);
         }
          currentRotY++;
       currentRotY = Mathf.Clamp(currentRotY,startRotY,endRotY);
       transform.rotation = Quaternion.Euler(0,currentRotY ,0);
     }
Now, here are the main problems:
- I need to control the speed of rotating around somehow, since it spins reeealy slow. 
- I can't look around anymore. The angle of camera is locked. I can wiggle around for a bit but it resets almost instantly to the starting angle. 
Any ideas?
Thanks, Kristoff
Your answer
 
 
             Follow this Question
Related Questions
How to lock camera angle on key press? 1 Answer
Rotate object in a set amount of time 1 Answer
Transform.Rotate() stuck at 90 and 270 degrees 3 Answers
Rotate 90 degrees over time with Parabolic Easing. 1 Answer
Rotate 90 over time on mouseDown 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                