playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - tchrisbaker

Pages: [1]
1
Attached is a template I created to move a character towards another character. It uses Navmesh Raycast to see if it can simply move forward (using a root motion animation). If not, it will use Unity pathfinding. I call it using RunFSM  every game loop. I think I put a small wait in between calls so it can reevaluate whether to use pathfinding or not.

2
Share New Actions / DoesColliderContainPoint
« on: July 15, 2016, 06:19:37 PM »
I created an action to find if a gameobject or a Vector3 point is in the bounds of a box collider. I found this pretty useful so thought I would share.

3
Playmaker Help / (SOLVED) See if an aninmation has finished
« on: July 14, 2016, 08:55:11 AM »
Is there an easy way to see if an animation has finished once you start it with a Set Animation Trigger action? I know I can have animation events which is great, but I wondered if there's a simple way to start an animation then find out if it has completed.

4
Share New Actions / Useful for NavMeshAgent debugging
« on: July 02, 2016, 01:07:19 AM »
I created a debugging action for tracking a character's NavMeshAgent path. It will draw a Debug line from the character to each point in the path.

If the path is white, it is complete and therefore successful, yellow is partial and red is invalid.

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Debug)]

public class PathUtils : FsmStateAction {
[RequiredField]
[Tooltip("The Game Object to work with. NOTE: The Game Object must have a NavMeshAgent component attached.")]
[CheckForComponent(typeof(NavMeshAgent))]
public FsmOwnerDefault gameObject;

private NavMeshAgent agent;

private Color color;

private void _getAgent()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}

agent =  go.GetComponent<NavMeshAgent>();
}

public override void OnEnter() {
_getAgent ();
}

public override void OnUpdate()
{
DrawPath (agent.path);
}

void DrawPath(NavMeshPath path) {
if (path.corners.Length < 2)
return;
switch (path.status) {
case NavMeshPathStatus.PathComplete:
color = Color.white;
break;
case NavMeshPathStatus.PathInvalid:
color = Color.red;
break;
case NavMeshPathStatus.PathPartial:
color = Color.yellow;
break;
}

Vector3 previousCorner = path.corners[0];

int i = 1;
while (i < path.corners.Length) {
Vector3 currentCorner = path.corners[i];
Debug.DrawLine(previousCorner, currentCorner, color);
previousCorner = currentCorner;
i++;
}
}
}
}


Pages: [1]