I'm attempting to make a script that when a spot is clicked on the stage the sprite will move to it. It is exactly the same as Warcraft3 where you select a unit, click somewhere, and it moves to it. So far I have the selector working to select single units and tried a code that I thought should have the basic functionality that I am looking for but it always tells the sprite to go to 0,0 and not where I clicked on the stage.
http://tinypic.com/r/ayohlh/6
That is what the code looks like that I thought would work.
The GoTo was initiated by a 'when stage is clicked'
Any help would be appreciated, thanks.
Offline
You're not moving the mouse to the middle after clicking? Is there perhaps another script sending it ti the middle?
Offline
No there isn't I am not on the computer where all my current work is, I wish I could link it all. I actually wasn't using the exact script that I posted. Here is the exact one that I was using http://tinypic.com/r/2zit3tk/6
I'm not sure why I added the extra 'x position of' seems a bit redundant. Maybe that was the problem. It seems to be reading the mouses x and y position as 0,0 all the time with the script that I was actually using. This could have been the problem but I doubt it.
Offline
It might have something to do with that when you click the mouse, it broadcasts Goto, but then the mouse is still clicked so it broadcasts it again and threfore the script restarts. Could you put what you've done so far on the scratch website please?
Offline
http://tinypic.com/r/vy0ajd/6
There is the picture of the code that works, I figured out the movement, the extra 'x position of' was the problem, or it was just acting weird previously.
I now face the problem of making it look realistic when walking. Here is my first attempt that failed. http://tinypic.com/r/2egenfm/6
Offline
Figured it all out!!!! Here are screenshots of all code. Please give credit where credit is due if my code is posted on other forums to answer similar questions or if you will be uploading a game and you found this helpful. I normally wouldn't ask this but I could not find anyone else showing how to do this.
http://tinypic.com/r/10z35w5/6
All I have left to do is figure out how to make proper costume changes so that he faces where he is moving. Also my 'Move' is broadcasted from the stage, 'When Stage is Clicked' 'Broadcast: Move' and the peon that has my green selector around it will move. If anyone wants to see my code for the selector just ask!
Offline