70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using KinematicCharacterController;
|
||
|
using System;
|
||
|
|
||
|
namespace KinematicCharacterController.Walkthrough.PlayerCameraCharacterSetup
|
||
|
{
|
||
|
public class MyCharacterController : MonoBehaviour, ICharacterController
|
||
|
{
|
||
|
public KinematicCharacterMotor Motor;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
// Assign to motor
|
||
|
Motor.CharacterController = this;
|
||
|
}
|
||
|
|
||
|
public void BeforeCharacterUpdate(float deltaTime)
|
||
|
{
|
||
|
// This is called before the motor does anything
|
||
|
}
|
||
|
|
||
|
public void UpdateRotation(ref Quaternion currentRotation, float deltaTime)
|
||
|
{
|
||
|
// This is called when the motor wants to know what its rotation should be right now
|
||
|
}
|
||
|
|
||
|
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||
|
{
|
||
|
// This is called when the motor wants to know what its velocity should be right now
|
||
|
}
|
||
|
|
||
|
public void AfterCharacterUpdate(float deltaTime)
|
||
|
{
|
||
|
// This is called after the motor has finished everything in its update
|
||
|
}
|
||
|
|
||
|
public bool IsColliderValidForCollisions(Collider coll)
|
||
|
{
|
||
|
// This is called after when the motor wants to know if the collider can be collided with (or if we just go through it)
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public void OnGroundHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport)
|
||
|
{
|
||
|
// This is called when the motor's ground probing detects a ground hit
|
||
|
}
|
||
|
|
||
|
public void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport)
|
||
|
{
|
||
|
// This is called when the motor's movement logic detects a hit
|
||
|
}
|
||
|
|
||
|
public void ProcessHitStabilityReport(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport hitStabilityReport)
|
||
|
{
|
||
|
// This is called after every hit detected in the motor, to give you a chance to modify the HitStabilityReport any way you want
|
||
|
}
|
||
|
|
||
|
public void PostGroundingUpdate(float deltaTime)
|
||
|
{
|
||
|
// This is called after the motor has finished its ground probing, but before PhysicsMover/Velocity/etc.... handling
|
||
|
}
|
||
|
|
||
|
public void OnDiscreteCollisionDetected(Collider hitCollider)
|
||
|
{
|
||
|
// This is called by the motor when it is detecting a collision that did not result from a "movement hit".
|
||
|
}
|
||
|
}
|
||
|
}
|