playMaker

Author Topic: Wandering Horse can't stay in it's enclosure!  (Read 2127 times)

CGB

  • Playmaker Newbie
  • *
  • Posts: 3
Wandering Horse can't stay in it's enclosure!
« on: March 17, 2014, 04:33:12 PM »
New to PlayMaker and after an afternoon of searching for a solution, the nob needs help!

In a 3D scene I have a horse enclosure with a few objects in it, a fence and the horse.  All of the objects have mesh colliders on them.  I created an empty game object, called it HorseFSM and made it a child of the horse object.

My FSM has 6 states in it (see picture below). 
  • Radar - Check if the player is within a range threshold.  If he isn't just loop until he is.
  • Random Position - Player is in range so start animation.  Get the horse position, generate random X and Z numbers, add them to current position and create a new Vector3.
  • Create Waypoint - Create a game object that has it's position as the Vector3 just created.
  • Move to Waypoint - I do a smooth look at, play the horse walking animation and do a move towards with a finish event specified (Done Moving)
  • Random Delay - Once I'm done moving, I stop the animation, play the idle animation and wait between 5 and 15 seconds.
  • Delete Waypoint - I delete the waypoint that's no longer needed and on the finish event, loop back to the Radar state.

This works create with the exception of walking thru walls and the fences.   :o

I've tried putting a box collider on the horse or a rigidbody but just can't seem to figure this out.

Any help would be appreciated.

Thanks,
-Claude.


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Wandering Horse can't stay in it's enclosure!
« Reply #1 on: March 17, 2014, 05:09:20 PM »
Move Towards is just letting it plow through anything. It doesn't care about the colliders.

This is always a tough one with AI, you probably want to get a Pathfinding solution into the project at this point or use a character controller or something that responds to those collisions and push the AI around with it. Using physics would also handle this, for the most part, as long as you stick to physics inputs and don't start explicitly changing or translating the object's position like Move Towards does.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

CGB

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Wandering Horse can't stay in it's enclosure!
« Reply #2 on: March 18, 2014, 11:46:47 AM »
Hey Lane, thanks for your reply.  I think I understand what you're saying, re: the physics aspect, but I find it odd that nobody (that I can find) has created such a simple AI to move NPCs in a 3D world.

You'd think this would be a simple thing to do with PlayMaker (and the reason why I purchased it)...

Maybe somebody else has suggestions on where to look for such an example.

Cheers!

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Wandering Horse can't stay in it's enclosure!
« Reply #3 on: March 18, 2014, 11:54:44 AM »
Here's an idea...

Make a large cube trigger inside the stable. When the horse eventually walks out of it the cube sends an event to the horse telling it to move to a random waypoint inside the cube. That way if it ever leaves or is ever pushed out for any reason its main goal is to get back inside the cube to continue wandering.

onTriggerExit - get horse back inside.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

CGB

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Wandering Horse can't stay in it's enclosure!
« Reply #4 on: March 19, 2014, 07:16:46 AM »
That's not a bad idea Sebaslive, but I still have the issue of physics.  My terrain is not flat, hard to see in the screen cap, but there's a mild slope in it.  So I'll have to figure out something involving a character controller and the mechanim move functions.

Cheers!