How do I make an actor follow the mouse

Modified: 2008/05/02 14:30 by 131.107.0.106 - Categorized as: Game Creator, How To Guides
Edit

Make an actor follow the mouse



Basic Idea: Define 'Motion' behavior that follows mouse.

Sample Game: Sample: http://www.popfly.com/users/team/HowDoI-FollowMouse

Details:
  • Define a behavior for mouse event 'Anywhere'

Actor->Behaviors->Event
Image

Follow Mouse Event (Click the image to view full size)


  • Define the motion for 'Mouse' and increase its speed to a big number (like 2000). Select motion direction as 'Toward'. This makes the actor snap to the location where the mouse was clicked. If you use lower speed, then actor will move slowly towards the mouse pointer.
Image

Follow Mouse Motion (Click the image to view full size)


Notes:
  • If you define the event as 'While Down' instead of 'Press' and set the motion to take place 'While Receiving Event' instead of 'Forever' then actor will move towards the mouse click only while mouse button is down.
  • By using 'Actor' instead of 'Mouse' in the 'Relative to' selection, you can make your actor follow or run away from another actor

Privacy. Terms of Use. Trademarks.
ScrewTurn Wiki version 2.0.22. Some of the icons created by FamFamFam.