- Home /
Problem with quaternion weapon sway
Hello, I'm trying to make a script where the weapon the player is holding sway when you move around but I'm getting an error The type 'UnityEngine.Quaternion' does not have a visible contructor(BCE0024), this is the code public var defaultPosition : Quaternion;
var swayAmount : float = 5.0;
var swayX;
var swayY;
var swaySpeed : float = 5.0;
var newPos : Quaternion;
var gun : GameObject;
function Start () {
defaultPosition = transform.localRotation;
}
function Update () {
swayX = Input.GetAxis("Mouse X") * Time.deltaTime * swayAmount;
swayY = Input.GetAxis("Mouse Y") * Time.deltaTime * swayAmount;
newPos = new Quaternion(defaultPosition.x - swayX, defaultPosition.y - swayY, defaultPosition.z);
gun.transform.localRotation = Quaternion.Lerp(gun.defaultPosition, newPos, swaySpeed * Time.deltaTime)
Thanks for the help.
I think you need to do some research on how Quaternions work. Quaternions are not positions, nor do they have anything to do with positions.
Answer by xSmurfKasketter · Mar 23, 2014 at 09:10 AM
that is usually because you need to use Quaternion.Euler
as i don't think you can instantiate a Quaternion directly
Your answer
Follow this Question
Related Questions
Gun Sway Script glitching 0 Answers
Gun sways way too much 0 Answers
Aim Down Sights and Weapon Sway not working unless animations are not assigned 0 Answers
How do i make my weapon sway? 2 Answers