- Home /
Make an object follow my controller, like a hand
So, I'm new into codding and I was looking at some online tutorials while i was trying to make this hand to follow the rotation based on my MouseLook that is assigned for that capsule:
if I turn right or left it follows me but if I look down the following happens
So I was trying to use the code below (from this tutorial https://www.youtube.com/watch?v=ay2SMb9-nEE ) but I was stuck with a error that said that I was using Vector 3 and the CamMouseLoook script as a variable but it was a type . The CamMouseLoook is my script for the MouseLook.
using UnityEngine;
using System.Collections;
public class GunScript : MonoBehaviour {
GameObject CameraObject;
public float targetXrotation;
public float targetYrotation;
public float targetXrotationV;
public float targetYrotationV;
public float rotateSpeed = 0.3f;
public float holdHeight = -0.5f;
public float holdSide = 0.5f;
// Use this for initialization
void Start () {
transform.position = CameraObject.transform.position + (Quaternion.Euler (0, targetYrotation, 0) * Vector3 (holdSide, holdHeight, 0));
targetXrotation = Mathf.SmoothDamp ( targetXrotation, CameraObject.GetComponent(CamMouseLoook).xRotation, targetXrotationV, rotateSpeed);
targetYrotation = Mathf.SmoothDamp ( targetYrotation, CameraObject.GetComponent(CamMouseLoook).yRotation, targetYrotationV, rotateSpeed);
}
// Update is called once per frame
void Update () {
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612094434im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
FPS: Use Different type of Crosshair motion 1 Answer
Top Down shooter mouse controls 2 Answers
Screen.lockCursor leaves mouse where it was 2 Answers
Detect whether the mouse has moved from left to right? 2 Answers
Script for camera movement using Arcball,Scripting Camera Movements with Arcball 0 Answers