Corgi Engine
v9.0
|
Public Types | |
enum | Directions { Directions.Clockwise, Directions.CounterClockwise } |
the potential directions this object can move towards More... | |
Public Member Functions | |
virtual void | ChangeDirection () |
Call this method to have the crawler change direction More... | |
virtual void | SetDirection (Directions newDirection) |
Use this method to set a new direction for the crawler More... | |
Public Attributes | |
bool | CanMove = true |
whether or not this crawler can move. If false, it'll stay where it is. More... | |
Directions | Direction = Directions.Clockwise |
the current direction this crawler is moving towards More... | |
float | Speed = 10f |
the speed at which the crawler should move along the surface More... | |
float | DistanceToSurface = 0.5f |
the distance from the surface at which the object should remain More... | |
LayerMask | SurfaceLayerMask = LayerManager.ObstaclesLayerMask |
the layers the object will consider as a crawlable surface More... | |
Transform | Model |
the visual representation of our crawler, usually nested under the top level containing the logic (the Crawler component) More... | |
bool | RotateModel = true |
whether or not to rotate the crawler's model to match its movement direction More... | |
float | RotationSpeed = 10f |
if RotateModel is true, the speed at which the model should rotate to match its movement direction More... | |
bool | FlipModelOnDirectionChange = true |
whether or not the model should flip its x scale as it changes direction More... | |
Vector2 | ForwardRaycastOffset = Vector2.zero |
the offset (from the crawler's position) from which we'll cast our forward ray More... | |
float | ForwardRaycastLength = 2f |
the length of the forward raycast. This raycast detects upcoming walls, so you'll want to make sure it's of appropriate length. Don't hesitate to enable debug gizmos and check if it behaves as you expect More... | |
Vector2 | DownwardRaycastOffset = Vector2.zero |
the offset (from the crawler's position) from which we'll cast our downward ray More... | |
float | DownwardRaycastLength = 2f |
the length of the downward raycast. This raycast detects the surface below the crawler, so you'll want to make sure it's of appropriate length. Don't hesitate to enable debug gizmos and check if it behaves as you expect More... | |
float | RaycastRotationAngleInterval = 10f |
when the crawler doesn't find a ground under itself, it'll start rotating on itself (in the movement's direction) until it finds a surface. This defines the increment at which it does that. The smaller the value, the more it will have to rotate to find ground. This should be tweaked based on the amount of different corner angles this crawler has to handle. If you only have right angles, then a value like 45 should be fine, for example. More... | |
int | MaxAmountOfRotations = 5 |
the maximum amount of rotations the object will perform on itself after reaching an edge to try and find new ground. You'll want to tweak it based on your level's geometry, angle interval and max distance to a potential wall behind on the path More... | |
float | MaxDistanceInterval = 0.5f |
the maximum distance interval between two movements. This should be adjusted based on the size of the crawler and the terrain it needs to navigate. That's the distance at which the crawler will reevaluate its path. More... | |
bool | DrawGizmos = true |
whether or not to draw gizmos in scene view to show the various raycasts More... | |
bool | ChangeDirectionButton |
Protected Member Functions | |
virtual void | Awake () |
On awake we initialize our crawler More... | |
virtual void | Initialization () |
On init we create a rotation reference we'll keep around as a reference of our current normal More... | |
virtual void | FixedUpdate () |
On fixed update we crawl and rotate our model More... | |
virtual void | PerformCrawl () |
Moves along the surface at the specified speed More... | |
virtual void | HandleModelOrientation () |
Changes the scale of the model to match its current direction More... | |
virtual void | HandleModelRotation () |
Rotates the model to tend towards the reference rotation at the specified speed More... | |
virtual void | DetermineDirection () |
Casts a number of rays to determine what direction the object should take next More... | |
virtual Vector2 | ComputeOffset (Transform t, Vector2 offset) |
Computes the offset based on the current direction and rotation of our crawler More... | |
virtual void | RegisterHit (RaycastHit2D hit, Vector2 offset) |
When we register a hit, we move at the specified distance and offset, and rotate our reference accordingly. More... | |
Protected Attributes | |
Vector2 | _previousNormal |
Vector2 | _raycastOrigin |
Vector2 | _movementDirection |
Vector3 | _translation |
Vector2 | _forwardRaycastDirection |
float | _movedDistance |
float | _targetDistance = 0f |
Transform | _rotationReference |
Vector2 | _initialModelScale |
Vector2 | _modelScale |
Quaternion | _initialRotation |
|
protectedvirtual |
On awake we initialize our crawler
|
virtual |
Call this method to have the crawler change direction
|
protectedvirtual |
Computes the offset based on the current direction and rotation of our crawler
t | |
offset |
|
protectedvirtual |
Casts a number of rays to determine what direction the object should take next
|
protectedvirtual |
On fixed update we crawl and rotate our model
|
protectedvirtual |
Changes the scale of the model to match its current direction
|
protectedvirtual |
Rotates the model to tend towards the reference rotation at the specified speed
|
protectedvirtual |
On init we create a rotation reference we'll keep around as a reference of our current normal
|
protectedvirtual |
Moves along the surface at the specified speed
|
protectedvirtual |
When we register a hit, we move at the specified distance and offset, and rotate our reference accordingly.
hit | |
offset |
|
virtual |
Use this method to set a new direction for the crawler
newDirection |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool MoreMountains.CorgiEngine.SurfaceCrawler.CanMove = true |
whether or not this crawler can move. If false, it'll stay where it is.
bool MoreMountains.CorgiEngine.SurfaceCrawler.ChangeDirectionButton |
Directions MoreMountains.CorgiEngine.SurfaceCrawler.Direction = Directions.Clockwise |
the current direction this crawler is moving towards
float MoreMountains.CorgiEngine.SurfaceCrawler.DistanceToSurface = 0.5f |
the distance from the surface at which the object should remain
float MoreMountains.CorgiEngine.SurfaceCrawler.DownwardRaycastLength = 2f |
the length of the downward raycast. This raycast detects the surface below the crawler, so you'll want to make sure it's of appropriate length. Don't hesitate to enable debug gizmos and check if it behaves as you expect
Vector2 MoreMountains.CorgiEngine.SurfaceCrawler.DownwardRaycastOffset = Vector2.zero |
the offset (from the crawler's position) from which we'll cast our downward ray
bool MoreMountains.CorgiEngine.SurfaceCrawler.DrawGizmos = true |
whether or not to draw gizmos in scene view to show the various raycasts
bool MoreMountains.CorgiEngine.SurfaceCrawler.FlipModelOnDirectionChange = true |
whether or not the model should flip its x scale as it changes direction
float MoreMountains.CorgiEngine.SurfaceCrawler.ForwardRaycastLength = 2f |
the length of the forward raycast. This raycast detects upcoming walls, so you'll want to make sure it's of appropriate length. Don't hesitate to enable debug gizmos and check if it behaves as you expect
Vector2 MoreMountains.CorgiEngine.SurfaceCrawler.ForwardRaycastOffset = Vector2.zero |
the offset (from the crawler's position) from which we'll cast our forward ray
int MoreMountains.CorgiEngine.SurfaceCrawler.MaxAmountOfRotations = 5 |
the maximum amount of rotations the object will perform on itself after reaching an edge to try and find new ground. You'll want to tweak it based on your level's geometry, angle interval and max distance to a potential wall behind on the path
float MoreMountains.CorgiEngine.SurfaceCrawler.MaxDistanceInterval = 0.5f |
the maximum distance interval between two movements. This should be adjusted based on the size of the crawler and the terrain it needs to navigate. That's the distance at which the crawler will reevaluate its path.
Transform MoreMountains.CorgiEngine.SurfaceCrawler.Model |
the visual representation of our crawler, usually nested under the top level containing the logic (the Crawler component)
float MoreMountains.CorgiEngine.SurfaceCrawler.RaycastRotationAngleInterval = 10f |
when the crawler doesn't find a ground under itself, it'll start rotating on itself (in the movement's direction) until it finds a surface. This defines the increment at which it does that. The smaller the value, the more it will have to rotate to find ground. This should be tweaked based on the amount of different corner angles this crawler has to handle. If you only have right angles, then a value like 45 should be fine, for example.
bool MoreMountains.CorgiEngine.SurfaceCrawler.RotateModel = true |
whether or not to rotate the crawler's model to match its movement direction
float MoreMountains.CorgiEngine.SurfaceCrawler.RotationSpeed = 10f |
if RotateModel is true, the speed at which the model should rotate to match its movement direction
float MoreMountains.CorgiEngine.SurfaceCrawler.Speed = 10f |
the speed at which the crawler should move along the surface
LayerMask MoreMountains.CorgiEngine.SurfaceCrawler.SurfaceLayerMask = LayerManager.ObstaclesLayerMask |
the layers the object will consider as a crawlable surface