- Home /
Object moving to mouse
Hello guys! Im trying to do a little Spiral Knights copy to test how much work can do, but, however in the programmers, i have a problem. I need to move my char to the mouse. When i get a mouse click, the Object moves toward the mouse, but when i release, stops. I dunno what can i do, i readed i will need a raycast, but i dont know how to apply this. Thx 4 help.
Sorry for my bad english, im from spain. Bad demostration in paint (LOL)
function Update (){
if (input.getkey(keycode.W){
transform.translate (mouse.X, mouse.Y);
}
}
//Shitty code lol
Edit your question to include the script you are using now, and someone can help fix it. If your code is already moving towards the mouse, the fix will likely not involve Raycasting.
This cannot possibly be the your current working code. I count eight syntax errors that could cause this code to not compile, and if you fixed them, this code would not cause the object to head towards the mouse. There are many posts on UA on getting an object to follow the mouse.
Your answer
Follow this Question
Related Questions
Moving arrows far away from object 1 Answer
C# trying to move a object 2 Answers
Move Sprite few steps from current location on tap 1 Answer