- 最后登录
- 2024-6-3
- 注册时间
- 2009-10-16
- 阅读权限
- 100
- 积分
- 18803
  
- 纳金币
- 17488
- 精华
- 1
|
Follow Mouse (Interactive Behavior)
Summary
Causes the object to follow the mouse around the screen.
Category
Latest Behaviors
Author
Gavin Kistner
Difficulty
(Reference)
Time to Complete
5 Minutes
Downloads
Click Here
to download the associated files.
(This document covers version 1.0.1 of the 'Follow Mouse' behavior, current as of 2005-Feb-11)
Description
The
When to Follow
property controls when the object follows the mouse. By default, the object always follows the mouse, but you can have it only occur when the mouse is down (much like the Draggable behavior), when a certain key is down, or a variety of other events. If you use the last option, “
(Action Controlled)
”, the object will only start following the mouse when the Start Following action is invoked on this behavior.
By default, the object reacts instantly to changes in the mouse position. The various Advanced Properties described below allow you to control how the object follows the mouse.
The
Follow Delay
property specifies how many frames the object should wait before following the mouse. For example, a value of ‘10’ means that the object will try to move to where the mouse was 10 frames ago, while the default value of 0 causes it to always move to where the mouse is right now.
The
Screen Offset
property specifies a fixed offset (in pixels) from the mouse position that the object should move towards. For example, a value of “50, -20, 0” will cause the object to move to a spot 50 pixels to the right and 20 pixels below where the cursor is. (The z value is always ignored.)
The
Spring Tension
property controls how hard the object is pulled to the desired spot. A value of 100 causes it to instantly snap to the desired spot, while a value of 50 causes it to move 50% of the distance each frame. Lower values give the object a smoother reaction to changes in the mouse position.
Finally, the
Holdoff Distance
is a fixed distance (in the object space) that the object should stay away from the mouse. This is similar to the
Screen Offset
, but
a) it is specified in world units, not pixels, and
b) it specifies only distance, not location.
Think of
Holdoff Distance
as a rigid pole attached between the end position and the object, which can pivot on both ends. The object will chase the mouse but stop before catching it, and if the mouse moves toward the object, it will push off to ensure it stays away from the mouse.
All properties can be used in any combination. (Although some combinations may produce ‘interesting’ effects.)
Basic Properties
When to Follow
When is this behavior active?
Trigger Key
If 'When to Follow' is 'Key Down', the name of the key to watch for.
Stop on Reverse?
Stop following the mouse when the 'opposite' event occurs?
Advanced Properties
Follow Delay
Number of frames behind the mouse to trail.
Screen Offset
Fixed X/Y offset from the mouse for the object move to.
Spring Tension
How strong is the 'spring' between the object and the mouse? (100 is a rigid attachment.)
Holdoff Distance
Distance away from the the mouse/offset to keep.
Actions
Start Following
Start applying this behavior.
Stop Following
Stop applying this behavior.
Toggle
If the parent is following the mouse, stop it; otherwise, start it.
Events
Started
Fires when the behavior is started.
Stopped
Fires when the behavior is stopped.
Demonstration
![]()
View Demonstration Project
![]()
Download Project File
|
|