Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using RAIN.Core;
- using RAIN.Action;
- using RAIN.Navigation;
- [RAINAction("Choose Wander Location2")]
- public class ChooseWanderTarget2 : RAINAction
- {
- // add in a cube and rename Indicator to display target location
- //private GameObject Indicator;
- public ChooseWanderTarget2()
- {
- actionName = "ChooseWanderTarget2";
- }
- public override void Start(AI ai)
- {
- base.Start(ai);
- // Use this to assign a cube with collider disabled called indicator to use and an idicator for target position
- //Indicator = GameObject.Find ("Indicator");
- }
- public override ActionResult Execute(AI ai)
- {
- Vector3 loc = Vector3.zero;
- RAIN.Navigation.Pathfinding.RAINPath myPath = null;
- do {
- loc = new Vector3(ai.Kinematic.Position.x + Random.Range(0f, 8f),
- ai.Kinematic.Position.y,
- ai.Kinematic.Position.z + Random.Range(-8f, 8f));
- } while ((Vector3.Distance(ai.Kinematic.Position, loc) < 1f) && !ai.Navigator.GetPathTo(loc, 10, out myPath));
- ai.WorkingMemory.SetItem<Vector3> ("wanderTarget", loc);
- // Use this to move the object (ie a cube to the target location
- //Indicator.transform.position = loc;
- return ActionResult.SUCCESS;
- }
- public override void Stop(AI ai)
- {
- base.Stop(ai);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement