Hey,
i am trying to write a mouse control script. I have found some nice mouse script and modified it. It use the following code to determinate the target location and move the Player trough the animator into that position. But sometimes (especial on ramps) it miss the target and keep running. What is my mistake?
if (Input.GetMouseButtonDown(0) GUIUtility.hotControl == 0) {
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
//Was haben wir getroffen ?
if (Physics.Raycast(ray, out hit, 2000)) {
Debug.Log(hit.collider.name);
if (hit.collider.tag == "Ground") { // Haben wir den Level Boden getroffen ? Tag = Ground
destinationPosition = ray.GetPoint(hitdist); // Speicher die Position ab
targetRotation = Quaternion.LookRotation(targetPoint - transform.position); // Die Rotation zum Ziel
//myTransform.rotation = targetRotation;
myTransform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * rotationSpeed);
}
}
}
Did i need to adjust my animations or is something with my raycast wrong?!
I hope someone of this great community can help - still learning unity.
Greetings
Luke