YouGroove Posted April 23, 2014 Share Posted April 23, 2014 http://www.leadwerks.com/werkspace/files/file/528-move-character-to-mouse-position/ Could be usefull for beginners or people needing some ready to use base code for "move to mouse character system". Enjoy I will bring some improvements as i use it in my own project, like more camera controls, or special visibility when character is hidden behind 3D models. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted April 23, 2014 Author Share Posted April 23, 2014 If i duplicate the crawler , why only one go to the point i clicked ? as they use same code ? Did i missed something ? Another point : The character orients to a strange direction when it reached the goal position using GotoPoint ,instead of keeping facing the direction given , it is a bug ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted April 24, 2014 Share Posted April 24, 2014 When I do this I always call Stop() when within a certain distance of destination. What you are seeing is probably floating point errors or something like that. As for your other problem you are using MouseHit() which will only register once per frame so it's registering for 1 enemy but not the other because they get processed in the same frame. That's my guess anyway with just looking at the code. One way to get around this and simulate a hit function like that is to give each script a bool value for mouse down and then do: if window:MouseDown(1) == true and self.mouseDown == false then -- do code here on mouse down self.mouseDown = true else if window:MouseDown(1) == false and self.mouseDown == true then -- do code here on mouse up after mouse down self.mouseDown = false end 2 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted April 24, 2014 Author Share Posted April 24, 2014 Thanks Rick. I updated the script with your MouseDown and Stop function and it's ok now Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.