- Home /
Make the player shoot towards a mouse click 2d Platformer
Similar to a system in Trine, I am really bad at raycasting and all of that type of stuff.
Thanks In Advance.
Comment
Answer by nventimiglia · Jul 04, 2012 at 12:56 PM
//get mouse position
var worldpoint = uiCamera.ScreenToWorldPoint(Input.mousePosition);
//convert to 3d for propulsion look at
return new Vector3(worldpoint.x, 0, worldpoint.y);
// Look at and dampen the rotation
var rotation = Quaternion.LookRotation(InputTurn);
var neR = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Turnrate);
transform.rotation = neR;
What object should i put that script on? The player?, Camera? etc.
looks like the script above will rotate the object it's attached to to face the mouse position... So attach to the player.
Your answer
Follow this Question
Related Questions
Shoot directions 2 Answers
Problem with raycasting in direction of mouse 0 Answers
I want to click on my screen and make my character move there, having trouble with raycasts. 1 Answer
How to make "enemy" have a frustum(cone) view and not a circle radius 2 Answers
Shooting with camera on rails 4 Answers