Bracer Jack | Smooth Rotation from Input in 49 Secs ! @BracerJack | Uploaded September 2015 | Updated October 2024, 4 days ago.
Script:
using UnityEngine;
using System.Collections;
public class GunScript : MonoBehaviour
{
public float Rotation_Speed;
public float Rotation_Friction; //The smaller the value, the more Friction there is. [Keep this at 1 unless you know what you are doing].
public float Rotation_Smoothness; //Believe it or not, adjusting this before anything else is the best way to go.
private float Resulting_Value_from_Input;
private Quaternion Quaternion_Rotate_From;
private Quaternion Quaternion_Rotate_To;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
Resulting_Value_from_Input += Input.GetAxis ("Horizontal") * Rotation_Speed * Rotation_Friction; //You can also use "Mouse X"
Quaternion_Rotate_From = transform.rotation;
Quaternion_Rotate_To = Quaternion.Euler (0,Resulting_Value_from_Input,0);
transform.rotation = Quaternion.Lerp (Quaternion_Rotate_From, Quaternion_Rotate_To, Time.deltaTime*Rotation_Smoothness);
}
}
Support me by reading my books !
===============================================================
Humpty Dumpty God
Google Play eBook:
play.google.com/store/books/details?id=I-_cDwAAQBAJ
Kindle eBook:
amazon.com/dp/B0875KWW4Z
Paperback:
amazon.com/dp/B087647N67
===============================================================
===============================================================
Book 1 :: God Guardian: The Life Review Simulation
Google Play eBook:
play.google.com/store/books/details?id=IxnRDwAAQBAJ
Kindle eBook:
amazon.com/dp/B07SGZLMK9
Paperback:
amazon.com/dp/1070820237
===============================================================
===============================================================
Book 2 :: God Guardian: Incarnation Troll
Google Play eBook:
play.google.com/store/books/details?id=RxnRDwAAQBAJ
Kindle eBook:
amazon.com/dp/B07SJ8TLV5
Paperback:
amazon.com/dp/1070940291
===============================================================
===============================================================
Book 3 :: God Guardian: Perpetual Slaves
Google Play eBook:
play.google.com/store/books/details?id=aRnRDwAAQBAJ
Kindle eBook:
amazon.com/dp/B084TJ6JKN
Paperback:
amazon.com/dp/B084QKYCML
===============================================================
Please support my Patreon:
patreon.com/BracerJack
Paypal Donation:
bracercom@hotmail.com
Bitcoin Address Donation:
1698RW9rSJUXeSSbyNaQY7aNNbxQkLtjs5
===============================================================
Script:
using UnityEngine;
using System.Collections;
public class GunScript : MonoBehaviour
{
public float Rotation_Speed;
public float Rotation_Friction; //The smaller the value, the more Friction there is. [Keep this at 1 unless you know what you are doing].
public float Rotation_Smoothness; //Believe it or not, adjusting this before anything else is the best way to go.
private float Resulting_Value_from_Input;
private Quaternion Quaternion_Rotate_From;
private Quaternion Quaternion_Rotate_To;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
Resulting_Value_from_Input += Input.GetAxis ("Horizontal") * Rotation_Speed * Rotation_Friction; //You can also use "Mouse X"
Quaternion_Rotate_From = transform.rotation;
Quaternion_Rotate_To = Quaternion.Euler (0,Resulting_Value_from_Input,0);
transform.rotation = Quaternion.Lerp (Quaternion_Rotate_From, Quaternion_Rotate_To, Time.deltaTime*Rotation_Smoothness);
}
}
Support me by reading my books !
===============================================================
Humpty Dumpty God
Google Play eBook:
play.google.com/store/books/details?id=I-_cDwAAQBAJ
Kindle eBook:
amazon.com/dp/B0875KWW4Z
Paperback:
amazon.com/dp/B087647N67
===============================================================
===============================================================
Book 1 :: God Guardian: The Life Review Simulation
Google Play eBook:
play.google.com/store/books/details?id=IxnRDwAAQBAJ
Kindle eBook:
amazon.com/dp/B07SGZLMK9
Paperback:
amazon.com/dp/1070820237
===============================================================
===============================================================
Book 2 :: God Guardian: Incarnation Troll
Google Play eBook:
play.google.com/store/books/details?id=RxnRDwAAQBAJ
Kindle eBook:
amazon.com/dp/B07SJ8TLV5
Paperback:
amazon.com/dp/1070940291
===============================================================
===============================================================
Book 3 :: God Guardian: Perpetual Slaves
Google Play eBook:
play.google.com/store/books/details?id=aRnRDwAAQBAJ
Kindle eBook:
amazon.com/dp/B084TJ6JKN
Paperback:
amazon.com/dp/B084QKYCML
===============================================================
Please support my Patreon:
patreon.com/BracerJack
Paypal Donation:
bracercom@hotmail.com
Bitcoin Address Donation:
1698RW9rSJUXeSSbyNaQY7aNNbxQkLtjs5
===============================================================