- Home /
This question was
closed Nov 21, 2017 at 11:10 PM by
MallardSam for the following reason:
The question is answered, right answer was accepted
Question by
MallardSam · Nov 21, 2017 at 09:24 PM ·
c#isometricmousefollow
Make my character point at the mouse in my Isometric game. C#
So I'm sort of new to unity, and I've been designing this game and I can't figure out a way to get my character to point towards my cursor. This is my desired effect: 
I've tried: Ray cameraRay;
RaycastHit cameraRayHit;
void Update () {
cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition);
// If the ray strikes an object...
if (Physics.Raycast(cameraRay, out cameraRayHit))
{
if(cameraRayHit.transform.tag=="Ground")
{
Vector3 targetPosition = new Vector3(cameraRayHit.point.x, transform.position.y, cameraRayHit.point.z);
transform.LookAt(targetPosition);
}
}
}
and transform.Rotate(0, Input.GetAxis("Mouse X") * -MouseSpeed, 0);
1.png
(92.9 kB)
Comment
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
I need help with moving a character in Unity2D c# but just along a path 0 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
How do I make my enemy have animations for directions during movemvent 1 Answer