Adventure Creator  1.55b
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2016
AC.Player Class Reference
Inheritance diagram for AC.Player:
AC.Char

Public Member Functions

void Initialise ()
 
override void _Update ()
 
void TankTurnLeft (float intensity=1f)
 Makes the Player spot-turn left during gameplay. This needs to be called every frame of the turn. More...
 
void TankTurnRight (float intensity=1f)
 Makes the Player spot-turn right during gameplay. This needs to be called every frame of the turn. More...
 
void CancelPathfindRecalculations ()
 Stops the Player from re-calculating pathfinding calculations.
 
void StopTurning ()
 
override float GetTurnFloat ()
 Gets the rate at which the character is turning (negative values used when turning anti-clockwise). More...
 
void ForceTurnFloat (float _value)
 
void Jump ()
 
new void EndPath ()
 
void SetLockedPath (Paths pathOb)
 Locks the Player to a Paths object during gameplay, if using Direct movement. This allows the designer to constrain the Player's movement to a Path, even though they can move freely along it. More...
 
bool IsLockedToPath ()
 Checks if the Player is constrained to move along a Paths object during gameplay. More...
 
override bool CanBeDirectControlled ()
 Checks if the character can be controlled directly at this time. More...
 
bool IsTilting ()
 
float GetTilt ()
 
void SetTilt (Vector3 lookAtPosition, bool isInstant)
 Sets the tilt of a first-person camera. More...
 
override void SetHeadTurnTarget (Transform _headTurnTarget, Vector3 _headTurnTargetOffset, bool isInstant, HeadFacing _headFacing=HeadFacing.Manual)
 Controls the head-facing position. More...
 
void SetHotspotHeadTurnLock (bool state)
 Sets the enabled state of Player's ability to head-turn towards Hotspots. More...
 
PlayerData SavePlayerData (PlayerData playerData)
 Updates a PlayerData class with its own variables that need saving. More...
 
void LoadPlayerData (PlayerData playerData)
 Updates its own variables from a PlayerData class. More...
 
- Public Member Functions inherited from AC.Char
void _LateUpdate ()
 
void _FixedUpdate ()
 
void RecalculateActivePathfind ()
 Rebuilds the active pathfind.
 
bool AccurateDestination ()
 Checks if the character should attempt to be as accurate as possible when moving to a destination. More...
 
void Teleport (Vector3 _position, bool recalculateActivePathFind=false)
 Teleports the character. The message 'OnTeleport' will be sent to the character's GameObject after the position is set. More...
 
void SetRotation (Quaternion _rotation)
 Instantly rotates the character More...
 
void SetRotation (float angle)
 Instantly rotates the Player More...
 
void SetLookDirection (Vector3 _direction, bool isInstant)
 Sets the intended direction to face. More...
 
void SetMoveDirection (Vector3 _direction)
 Moves the character in a particular direction. More...
 
void SetMoveDirectionAsForward ()
 
void SetMoveDirectionAsBackward ()
 
Animation GetAnimation ()
 Gets the character's Animation component. More...
 
Animator GetAnimator ()
 Gets the character's Animator component. An Animator placed on the spriteChild GameObject will be given priority. More...
 
void ResetAnimator ()
 
Vector3 GetMoveDirection ()
 Gets the direction that the character is moving in. More...
 
bool WillStopAtNextNode ()
 
void EndPath ()
 Stops the character from moving along the current Paths object.
 
void ResumeLastPath ()
 
void Halt ()
 
void ForceIdle ()
 
bool IsTurningBeforeWalking ()
 Checks if the character is spot-turning before making their move. isTurningBeforeWalking must be True for this to ever be the case. More...
 
void SetPath (Paths pathOb, PathSpeed _speed)
 Assigns the character to a Paths object to move along. This is not the same as pathfinding - this assumes a path has already been defined. More...
 
void SetPath (Paths pathOb)
 Assigns the character to a Paths object to move along. This is not the same as pathfinding - this assumes a path has already been defined. More...
 
void SetPath (Paths pathOb, int _targetNode, int _prevNode)
 Assigns the character to a Paths object to move along. This is not the same as pathfinding - this assumes a path has already been defined. More...
 
void SetPath (Paths pathOb, int _targetNode, int _prevNode, bool affectY)
 Assigns the character to a Paths object to move along. This is not the same as pathfinding - this assumes a path has already been defined. More...
 
Paths GetPath ()
 Gets the current Paths object that the character is moving along. If the character is pathfinding, the Paths component on the character's root will be returned. More...
 
void MoveToPoint (Vector3 point, bool run=false, bool usePathfinding=false)
 Moves towards a point in the scene. More...
 
void MoveAlongPoints (Vector3[] pointData, bool run, bool allowUpdating=true)
 Moves along a series of points in the scene. More...
 
void ResetBaseClips ()
 
float GetSpriteAngle ()
 Gets the angle that a 2D character's sprite is facing, relative to the root. More...
 
string GetSpriteDirection ()
 Gets the suffix to add to sprite animations that account for the facing direction - e.g. "Walk" -> "Walk_DR". More...
 
int GetSpriteDirectionInt ()
 Gets the direction that a 2D character is facing (Down = 0, Left = 1, Right = 2, Up = 3, DownLeft = 4, DownRight = 5, UpLeft = 6, UpRight = 7) More...
 
void SetSpriteDirection (CharDirection direction)
 Locks a 2D character's sprite to face a particular direction. More...
 
void SetSorting (int order)
 Locks the Renderer's sortingOrder. More...
 
void SetSorting (string layer)
 Locks the Renderer's sorting layer. More...
 
void ReleaseSorting ()
 
float GetMoveSpeed (bool reduceNonFacing=false)
 Gets the current movement speed. More...
 
void ClearHeadTurnTarget (bool isInstant, HeadFacing _headFacing)
 Ceases a particular type of head-facing. More...
 
void ClearHeadTurnTarget (bool isInstant)
 Stops the head from facing a fixed point. More...
 
void SnapHeadMovement ()
 
bool IsMovingHead ()
 Checks if the head is rotating to face its target, but has not yet reached it. More...
 
Shapeable GetShapeable ()
 Gets the Shapeable script component attached to the GameObject's root or child. More...
 
Vector3 GetHeadTurnTarget ()
 Gets the position of where the character's head is facing towards. More...
 
bool HoldObject (GameObject objectToHold, Hand hand)
 Parents an object to the character's hand More...
 
void ReleaseHeldObjects ()
 
Vector2 GetScreenCentre ()
 Gets the position of the top of the character, in screen-space. More...
 
void AfterLoad ()
 
void StartLipSync (List< LipSyncShape > _lipSyncShapes)
 Begins a lip-syncing animation based on a series of LipSyncShapes. More...
 
int GetLipSyncFrame ()
 Gets the current lip-sync frame. More...
 
float GetLipSyncNormalised ()
 Gets the current lip-sync frame, as a fraction of the total number of phoneme frames. More...
 
bool LipSyncGameObject ()
 Checks if the character is playing a lip-sync animation that affects the GameObject. More...
 
void StopSpeaking ()
 
int GetExpressionID (string expressionLabel)
 Gets the ID number of the Expression that has a specific label. More...
 
int GetExpressionID ()
 Gets the ID number of the currently-active Expression. More...
 
void ClearExpression ()
 
void SetExpression (int ID)
 Changes the active Expression. More...
 
CursorIconBase GetPortrait ()
 Gets the active portrait that's displayed in a MenuGraphic element when the character speaks. The portrait can change if an Expression has been defined.
 
bool IsGrounded ()
 Checks if the character (if 3D) is in contact with the ground. More...
 
MotionControl GetMotionControl ()
 Gets the extent to which motion is controlled by the character script (Automatic, JustTurning, Manual). More...
 
Vector3 GetTargetPosition ()
 Gets the character's destination when walking along a path. More...
 
Quaternion GetTargetRotation ()
 Gets the character's target rotation. More...
 
AnimEngine GetAnimEngine ()
 Gets the character's AnimEngine ScriptableObject. More...
 
void SetAnimEngine (AnimationEngine _animationEngine, string customClassName="")
 Sets the character's AnimEngine ScriptableObject. More...
 
float GetHeightChange ()
 Gets the character's change in height over the last frame. More...
 
bool IsReversing ()
 Checks if the character is moving backwards. More...
 
bool IsTurning ()
 Checks if the character is turning. More...
 
bool IsMovingAlongPath ()
 Checks if the character is moving along a path. More...
 
string GetName (int languageNumber=0)
 Gets the Character's current display name. More...
 
void SetName (string newName, int _lineID)
 Renames the Character mid-game. More...
 

Public Attributes

AnimationClip jumpAnim
 
string jumpParameter = "Jump"
 
int ID
 
DetectHotspots hotspotDetector
 
- Public Attributes inherited from AC.Char
CharState charState
 
AnimationEngine animationEngine = AnimationEngine.SpritesUnity
 
string customAnimationClass = ""
 
MotionControl motionControl = MotionControl.Automatic
 
TalkingAnimation talkingAnimation = TalkingAnimation.Standard
 
string speechLabel = ""
 
int lineID = -1
 
int displayLineID = -1
 
Color speechColor = Color.white
 
CursorIconBase portraitIcon = new CursorIconBase ()
 
bool useExpressions
 
List< Expressionexpressions = new List<Expression>()
 
Transform speechMenuPlacement
 
bool isLipSyncing = false
 
string phonemeParameter = ""
 
int lipSyncGroupID
 
Transform leftHandBone
 
Transform rightHandBone
 
AnimationClip idleAnim
 
AnimationClip walkAnim
 
AnimationClip runAnim
 
AnimationClip talkAnim
 
AnimationClip turnLeftAnim
 
AnimationClip turnRightAnim
 
AnimationClip headLookLeftAnim
 
AnimationClip headLookRightAnim
 
AnimationClip headLookUpAnim
 
AnimationClip headLookDownAnim
 
Transform upperBodyBone
 
Transform leftArmBone
 
Transform rightArmBone
 
Transform neckBone
 
float animCrossfadeSpeed = 0.2f
 
string moveSpeedParameter = "Speed"
 
string verticalMovementParameter = ""
 
string turnParameter = ""
 
string talkParameter = "IsTalking"
 
string directionParameter = "Direction"
 
string angleParameter = "Angle"
 
string headYawParameter = ""
 
string headPitchParameter = ""
 
string expressionParameter = ""
 
float rootTurningFactor = 0f
 
int headLayer = 1
 
int mouthLayer = 2
 
Transform spriteChild
 
RotateSprite3D rotateSprite3D = RotateSprite3D.CameraFacingDirection
 
string idleAnimSprite = "idle"
 
string walkAnimSprite = "walk"
 
string runAnimSprite = "run"
 
string talkAnimSprite = "talk"
 
bool lockScale = false
 
float spriteScale = 1f
 
bool lockDirection = false
 
string spriteDirection = "D"
 
bool doDirections = true
 
bool crossfadeAnims = false
 
bool doDiagonals = false
 
bool isTalking = false
 
AC_2DFrameFlipping frameFlipping = AC_2DFrameFlipping.None
 
bool flipCustomAnims = false
 
float walkSpeedScale = 2f
 
float runSpeedScale = 6f
 
float turnSpeed = 7f
 
float acceleration = 6f
 
float deceleration = 0f
 
bool turnBeforeWalking = false
 
float runDistanceThreshold = 1f
 
bool antiGlideMode = false
 
bool isJumping = false
 
bool ignoreGravity = false
 
bool freezeRigidbodyWhenIdle = false
 
bool doWallReduction = false
 
string wallLayer = "Default"
 
float wallDistance = 0.5f
 
AudioClip walkSound
 
AudioClip runSound
 
AudioClip textScrollClip
 
Sound soundChild
 
AudioSource speechAudioSource
 
Transform headTurnTarget
 
Vector3 headTurnTargetOffset
 
HeadFacing headFacing = HeadFacing.None
 
bool ikHeadTurning = false
 

Protected Member Functions

override void Accelerate ()
 
- Protected Member Functions inherited from AC.Char
void _Awake ()
 
void PathUpdate ()
 
float GetTargetSpeed ()
 
void AccurateAcc (float targetSpeed, bool canStop)
 
void SetLastPath (Paths _lastPathActivePath, int _lastPathTargetNode, int _lastPathPrevNode)
 
void ReverseDirection ()
 
void CheckIfStuck ()
 
int GetTargetNode ()
 
int GetPrevNode ()
 
Paths GetLastPath ()
 
int GetLastTargetNode ()
 
int GetLastPrevNode ()
 
void PrepareSpriteChild (bool isTopDown, bool isUnity2D)
 
void UpdateSpriteChild (bool isTopDown, bool isUnity2D)
 

Properties

Transform FirstPersonCamera [get, set]
 Assigns or sets the FirstPersonCamera Transform. This is done automatically in regular First Person mode, but must be set manually if using a custom controller, eg. Ultimate FPS.
 
- Properties inherited from AC.Char
bool isRunning [get, set]
 

Additional Inherited Members

- Protected Attributes inherited from AC.Char
Quaternion newRotation
 
float pathfindUpdateTime = 0f
 
float turnFloat = 0f
 
Rigidbody _rigidbody = null
 
Collider _collider = null
 
CharacterController _characterController
 
AudioSource audioSource
 
Paths activePath = null
 
float moveSpeed
 
Vector3 moveDirection
 
int targetNode = 0
 
bool pausePath = false
 
Vector3 lookDirection
 
bool tankTurning = false
 

Detailed Description

Attaching this component to a GameObject and tagging it "Player" will make it an Adventure Creator Player.

Member Function Documentation

override void AC.Player._Update ( )
virtual

The Player's "Update" function, called by StateHandler.

Reimplemented from AC.Char.

override bool AC.Player.CanBeDirectControlled ( )
virtual

Checks if the character can be controlled directly at this time.

Returns
True if the character can be controlled directly at this time

Reimplemented from AC.Char.

override float AC.Player.GetTurnFloat ( )
virtual

Gets the rate at which the character is turning (negative values used when turning anti-clockwise).

Returns
The rate at which the character is turning (negative values used when turninng anti-clockwise)

Reimplemented from AC.Char.

void AC.Player.Initialise ( )

Initialises the Player's animation.

bool AC.Player.IsLockedToPath ( )

Checks if the Player is constrained to move along a Paths object during gameplay.

Returns
True if the Player is constrained to move along a Paths object during gameplay
void AC.Player.Jump ( )

Causes the Player to jump, so long as a Rigidbody component is attached.

void AC.Player.LoadPlayerData ( PlayerData  playerData)

Updates its own variables from a PlayerData class.

Parameters
playerDataThe PlayerData class to load from
PlayerData AC.Player.SavePlayerData ( PlayerData  playerData)

Updates a PlayerData class with its own variables that need saving.

Parameters
playerDataThe original PlayerData class
Returns
The updated PlayerData class
override void AC.Player.SetHeadTurnTarget ( Transform  _headTurnTarget,
Vector3  _headTurnTargetOffset,
bool  isInstant,
HeadFacing  _headFacing = HeadFacing.Manual 
)
virtual

Controls the head-facing position.

Parameters
_headTurnTargetThe Transform to face
_headTurnTargetOffsetThe position offset of the Transform
isInstantIf True, the head will turn instantly
_headFacingWhat the head should face (Manual, Hotspot, None)

Reimplemented from AC.Char.

void AC.Player.SetHotspotHeadTurnLock ( bool  state)

Sets the enabled state of Player's ability to head-turn towards Hotspots.

Parameters
stateIf True, the Player's head will unable to face Hotspots
void AC.Player.SetLockedPath ( Paths  pathOb)

Locks the Player to a Paths object during gameplay, if using Direct movement. This allows the designer to constrain the Player's movement to a Path, even though they can move freely along it.

Parameters
pathObThe Paths to lock the Player to
void AC.Player.SetTilt ( Vector3  lookAtPosition,
bool  isInstant 
)

Sets the tilt of a first-person camera.

Parameters
lookAtPositionThe point in World Space to tilt the camera towards
isInstantIf True, the camera will be rotated instantly
void AC.Player.StopTurning ( )

Stops the Player from turning.

void AC.Player.TankTurnLeft ( float  intensity = 1f)

Makes the Player spot-turn left during gameplay. This needs to be called every frame of the turn.

Parameters
intensityThe relative speed of the turn. Set this to the value of the input axis for smooth movement.
void AC.Player.TankTurnRight ( float  intensity = 1f)

Makes the Player spot-turn right during gameplay. This needs to be called every frame of the turn.

Parameters
intensityThe relative speed of the turn. Set this to the value of the input axis for smooth movement.

Member Data Documentation

DetectHotspots AC.Player.hotspotDetector

The DetectHotspots component used if SettingsManager's hotspotDetection = HotspotDetection.PlayerVicinity

int AC.Player.ID

A unique identifier

AnimationClip AC.Player.jumpAnim

The Player's jump animation, if using Legacy animation

string AC.Player.jumpParameter = "Jump"

The name of the "Jump" boolean parameter, if using Mecanim animation