Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Javascript Gun Look Script Problems

$
0
0
I have been trying to implement a basic gun and i have got all the functionality enabled except the gun moving up and down. It rotates up and down but does not move with the camera. Here is a video of the problem: [Unity gun problem][1] Here is the gun code: #pragma strict var cameraObject : GameObject; @HideInInspector var targetXRotation : float; @HideInInspector var targetYRotation : float; @HideInInspector var targetXRotationV : float; @HideInInspector var targetYRotationV : float; var rotateSpeed : float = 0.1; var gunPosHeight : float = -0.1; var gunPosSide : float = 0.65; var gunPosZ : float = 1.12; function Update () { transform.position = cameraObject.transform.position + (Quaternion.Euler(0, targetYRotation, 0) * Vector3(gunPosSide, gunPosHeight, gunPosZ)); targetXRotation = Mathf.SmoothDamp(targetXRotation, cameraObject.GetComponent(mouseLook).xRotation, targetXRotationV, rotateSpeed); targetYRotation = Mathf.SmoothDamp(targetYRotation, cameraObject.GetComponent(mouseLook).yRotation, targetYRotationV, rotateSpeed); transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0); } [1]: https://www.youtube.com/watch?v=AmkN9JeBYR8&feature=youtu.be

Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>