Adventure Creator  1.66.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2018
AC.Moveable_Drag Class Reference
Inheritance diagram for AC.Moveable_Drag:
AC.DragBase AC.Moveable

Public Member Functions

float GetPositionAlong ()
 Gets how far the object is along its DragTrack. More...
 
override void UpdateMovement ()
 
override void DrawGrabIcon ()
 
override void ApplyDragForce (Vector3 force, Vector3 mousePosition, float _distanceToCamera)
 Applies a drag force on the object, based on the movement of the cursor. More...
 
override void LetGo ()
 
override void Grab (Vector3 grabPosition)
 Attaches the object to the player's control. More...
 
void UpdateScrewVector ()
 
void StopAutoMove (bool snapToTarget=true)
 Stops the object from moving without the player's direct input (i.e. through Actions). More...
 
bool IsAutoMoving ()
 Checks if the object is moving without the player's direct input. More...
 
void AutoMoveAlongTrack (float _targetTrackValue, float _targetTrackSpeed, bool removePlayerControl)
 Forces the object to move along a DragTrack without the player's direct input. More...
 
void AutoMoveAlongTrack (float _targetTrackValue, float _targetTrackSpeed, bool removePlayerControl, LayerMask layerMask)
 Forces the object to move along a DragTrack without the player's direct input. More...
 
- Public Member Functions inherited from AC.DragBase
void TurnOn ()
 
void TurnOff ()
 
virtual bool CanToggleCursor ()
 
bool IsOnScreen ()
 Checks if the the point of contact is visible on-screen. More...
 
bool IsCloseToCamera (float maxDistance)
 Checks if the point of contact is close enough to the camera to continue being held. More...
 
Vector3 GetGrabPosition ()
 Gets the point of contact on the object, once grabbed. More...
 
- Public Member Functions inherited from AC.Moveable
void StopMoving ()
 
bool IsMoving (TransformType transformType)
 
void EndMovement ()
 
void Move (Vector3 _newVector, MoveMethod _moveMethod, bool _inWorldSpace, float _transitionTime, TransformType _transformType, bool _doEulerRotation, AnimationCurve _timeCurve, bool clearExisting)
 Moves the GameObject by referencing a Vector3 as its target Transform. More...
 
void Move (Marker _marker, MoveMethod _moveMethod, bool _inWorldSpace, float _transitionTime, AnimationCurve _timeCurve)
 Moves the GameObject by referencing a Marker component as its target Transform. More...
 
MoveableData SaveData (MoveableData saveData)
 Updates a MoveableData class with its own variables that need saving. More...
 
void LoadData (MoveableData saveData)
 Updates its own variables from a MoveableData class. More...
 

Public Attributes

DragMode dragMode = DragMode.LockToTrack
 
DragTrack track
 
bool retainOriginalTransform = false
 
bool setOnStart = true
 
float trackValueOnStart = 0f
 
Interaction interactionOnMove = null
 
AlignDragMovement alignMovement = AlignDragMovement.AlignToCamera
 
Transform plane
 
bool noGravityWhenHeld = true
 
float colliderRadius = 0.5f
 
float trackValue
 
Vector3 _dragVector
 
Collider maxCollider
 
Collider minCollider
 
int revolutions = 0
 
- Public Attributes inherited from AC.DragBase
bool isHeld = false
 
bool invertInput = false
 
float maxSpeed = 200f
 
float playerMovementReductionFactor = 0f
 
float playerMovementInfluence = 1f
 
bool allowZooming = false
 
float zoomSpeed = 60f
 
float minZoom = 1f
 
float maxZoom = 3f
 
float rotationFactor = 1f
 
Rigidbody _rigidbody
 
bool showIcon = false
 
int iconID = -1
 
AudioClip moveSoundClip
 
AudioClip collideSoundClip
 
float slideSoundThreshold = 0.03f
 
float slidePitchFactor = 1f
 
bool onlyPlayLowerCollisionSound = false
 
bool ignoreMoveableRigidbodies
 
bool ignorePlayerCollider
 
bool childrenShareLayer
 

Protected Member Functions

override void Awake ()
 
- Protected Member Functions inherited from AC.DragBase
virtual void Start ()
 
void BaseOnCollisionEnter (Collision collision)
 
void PlayMoveSound (float speed, float trackValue)
 
void UpdateZoom ()
 
void LimitZoom ()
 

Additional Inherited Members

- Protected Attributes inherited from AC.DragBase
Transform grabPoint
 
Transform cameraTransform
 
float distanceToCamera
 
float speedFactor = 0.16f
 
float originalDrag
 
float originalAngularDrag
 
int numCollisions = 0
 
CursorIconBase icon
 
Sound collideSound
 
Sound moveSound
 

Detailed Description

Attaching this component to a GameObject allows it to be dragged, through physics, according to a set method.

Member Function Documentation

◆ ApplyDragForce()

override void AC.Moveable_Drag.ApplyDragForce ( Vector3  force,
Vector3  mousePosition,
float  _distanceToCamera 
)
virtual

Applies a drag force on the object, based on the movement of the cursor.

Parameters
forceThe force vector to apply
mousePositionThe position of the mouse
_distanceToCameraThe distance between the object's centre and the camera

Reimplemented from AC.DragBase.

◆ AutoMoveAlongTrack() [1/2]

void AC.Moveable_Drag.AutoMoveAlongTrack ( float  _targetTrackValue,
float  _targetTrackSpeed,
bool  removePlayerControl 
)

Forces the object to move along a DragTrack without the player's direct input.

Parameters
_targetTrackValueThe intended proportion along the track to send the object to
_targetTrackSpeedThe intended speed to move the object by
removePlayerControlIf True and the player is currently moving the object, then player control will be removed

◆ AutoMoveAlongTrack() [2/2]

void AC.Moveable_Drag.AutoMoveAlongTrack ( float  _targetTrackValue,
float  _targetTrackSpeed,
bool  removePlayerControl,
LayerMask  layerMask 
)

Forces the object to move along a DragTrack without the player's direct input.

Parameters
_targetTrackValueThe intended proportion along the track to send the object to
_targetTrackSpeedThe intended speed to move the object by
removePlayerControlIf True and the player is currently moving the object, then player control will be removed
layerMaskA LayerMask that determines what collisions will cause the automatic movement to cease

◆ DrawGrabIcon()

override void AC.Moveable_Drag.DrawGrabIcon ( )
virtual

Draws an icon at the point of contact on the object, if appropriate.

Reimplemented from AC.DragBase.

◆ GetPositionAlong()

float AC.Moveable_Drag.GetPositionAlong ( )

Gets how far the object is along its DragTrack.

Returns
How far the object is along its DragTrack. This is normally 0 to 1, but if the object is locked to a looped DragTrack_Hinge, then the number of revolutions will be added to the result.

◆ Grab()

override void AC.Moveable_Drag.Grab ( Vector3  grabPosition)
virtual

Attaches the object to the player's control.

Parameters
grabPositionThe point of contact on the object

Reimplemented from AC.DragBase.

◆ IsAutoMoving()

bool AC.Moveable_Drag.IsAutoMoving ( )

Checks if the object is moving without the player's direct input.

Returns
True if the object is moving without the player's direct input (gravity doesn't count).

◆ LetGo()

override void AC.Moveable_Drag.LetGo ( )
virtual

Detaches the object from the player's control.

Reimplemented from AC.DragBase.

◆ StopAutoMove()

void AC.Moveable_Drag.StopAutoMove ( bool  snapToTarget = true)

Stops the object from moving without the player's direct input (i.e. through Actions).

Parameters
snapToTargetIf True, then the object will snap instantly to the intended target position

◆ UpdateMovement()

override void AC.Moveable_Drag.UpdateMovement ( )
virtual

Called every frame by StateHandler.

Reimplemented from AC.DragBase.

◆ UpdateScrewVector()

void AC.Moveable_Drag.UpdateScrewVector ( )

If the object rotates like a screw along a DragTrack_Straight, this updates the correct drag vector.

Member Data Documentation

◆ _dragVector

Vector3 AC.Moveable_Drag._dragVector

A vector used in drag calculations

◆ alignMovement

AlignDragMovement AC.Moveable_Drag.alignMovement = AlignDragMovement.AlignToCamera

What movement is aligned to, if dragMode = DragMode.MoveAlongPlane (AlignToCamera, AlignToPlane)

◆ colliderRadius

float AC.Moveable_Drag.colliderRadius = 0.5f

The radius of the GameObject's SphereCollider, if it has one

◆ dragMode

DragMode AC.Moveable_Drag.dragMode = DragMode.LockToTrack

The way in which the object can be dragged (LockedToTrack, MoveAlongPlane, RotateOnly)

◆ interactionOnMove

Interaction AC.Moveable_Drag.interactionOnMove = null

The Interaction to run whenever the object is moved by the player

◆ maxCollider

Collider AC.Moveable_Drag.maxCollider

The upper-limit collider when locked to a DragTrack.

◆ minCollider

Collider AC.Moveable_Drag.minCollider

The lower-limit collider when locked to a DragTrack

◆ noGravityWhenHeld

bool AC.Moveable_Drag.noGravityWhenHeld = true

If True, then gravity will be disabled on the object while it is held by the player

◆ plane

Transform AC.Moveable_Drag.plane

The plane to align movement to, if alignMovement = AlignDragMovement.AlignToPlane

◆ retainOriginalTransform

bool AC.Moveable_Drag.retainOriginalTransform = false

If True, and dragMode = DragMode.LockToTrack, then the position and rotation of all child objects will be maintained when the object is attached to the track

◆ revolutions

int AC.Moveable_Drag.revolutions = 0

The number of revolutions the object has been rotated by, if placed on a DragTrack_Hinge

◆ setOnStart

bool AC.Moveable_Drag.setOnStart = true

If True, and the object is locked to a DragTrack, then the object will be placed at a specific point along the track when the game begins

◆ track

DragTrack AC.Moveable_Drag.track

The DragTrack the object is locked to (if dragMode = DragMode.LockToTrack

◆ trackValue

float AC.Moveable_Drag.trackValue

How far along a track the object is, if it is locked to one

◆ trackValueOnStart

float AC.Moveable_Drag.trackValueOnStart = 0f

How far along its DragTrack that the object should be placed at when the game begins