I'm trying to script my cube to rotate on the x-as around himself towards the mouse position. But I'm getting an error: error CS1503: Argument 1: cannot convert from 'UnityEngine.Vector3' to 'float' What I understand is the value given in angle_vector is wrong, but I didn't exactly understand what to change. Code (CSharp): // store mouse position Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition + Vector3.right * 10f); var angle_vector = new Vector3(mouseWorldPosition, 0, 0); transform.Rotate(angle_vector * rotate, Space.Self);
I tried some new things out but nothing seems to work. Code (CSharp): // Store mouse position Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; transform.Rotate(mouseWorldPosition, 0, 0); // Create quaternion //Quaternion rotation = Quaternion.LookRotation(mouseWorldPosition); //transform.rotation = Quaternion.Lerp(transform.rotation, rotation, speed * Time.deltaTime);
The same effect, the cube is just floating through space. But I found a script that works the way I want, I looked at it and it makes sense.