static int SortByDistance(SteeringAgent a1, SteeringAgent a2) { float distanceToPointA1 = Vector3.Distance(m_Hitpoint, a1.GetPosition()); float distanceToPointA2 = Vector3.Distance(m_Hitpoint, a2.GetPosition()); return(distanceToPointA1.CompareTo(distanceToPointA2) * -1); //return distanceToPointA1.CompareTo(distanceToPointA2); }
public Flocking(SteeringAgent owner) : base(owner) { addBehaviour(new Arrival(owner), 1f); addBehaviour(new Separation(owner), 1f); addBehaviour(new Cohesion(owner), 0.2f); addBehaviour(new Alignment(owner), 1f); }
public void Init(SteeringAgent agent, SteeringController steering, RigidbodyMovementController physicsController) { this.agent = agent; this.steering = steering; this.physicsController = physicsController; pathManager = PathManager.Instance; TargetPosition = agent.transform.position + agent.transform.forward; racingLineProgress = pathManager.RacingLinePath.path.GetClosestProgressOnPath(agent.transform.position); }
public override SteeringOutput CalculateSteering(SteeringAgent agent) { SteeringOutput steering = new SteeringOutput(); steering.LinearVelocity = m_Target - agent.GetPosition(); steering.LinearVelocity.Normalize(); steering.LinearVelocity *= agent.GetMaxLinearSpeed(); steering.IsValid = true; return(steering); }
// Awake is called when the script instance is being loaded private void Awake() { for (int i = 0; i < spawnCount; i++) { Vector3 pos = transform.position + Random.insideUnitSphere * spawnRadius; SteeringAgent boid = Instantiate(prefab); boid.transform.position = pos; boid.transform.forward = Random.insideUnitSphere.normalized; boid.SetColor(Random.ColorHSV(0, 1, 1, 1, 1, 1)); } }
// Use this for initialization void Start() { if (globalGameScript == null) { globalGameScript = GameObject.Find("GlobalGameScript").GetComponent <GlobalGameScript>(); } steeringAgent = GetComponent <SteeringAgent>(); seekScript = GetComponent <Seek>(); startingPosition = transform.position; // for debugging }
public override SteeringOutput CalculateSteering(SteeringAgent agent) { Vector3 offset = agent.GetVelocity(); offset.Normalize(); offset *= m_OffsetDistance; m_WanderAngle += Random.Range(-0.5f, 0.5f) * m_MaxAngleChange; Vector3 circleOffset = new Vector3(Mathf.Cos(m_WanderAngle) * m_Radius, 0, Mathf.Sin(m_WanderAngle) * m_Radius); m_Target = agent.GetPosition() + offset + circleOffset; return(base.CalculateSteering(agent)); }
public override Vector3 UpdateBehaviour(SteeringAgent steeringAgent) { Vector3 targetPosition = steeringAgent.seekTarget.transform.position; Vector3 leftRay = transform.position; Vector3 rightRay = transform.position; Vector3 direction = Vector3.Normalize(targetPosition - transform.position); desiredVelocity = direction * steeringAgent.maxSpeed; steeringVelocity = (desiredVelocity - steeringAgent.currentVelocity) * steeringAgent.seekWeight; return(steeringVelocity); }
public override Vector3 UpdateBehaviour(SteeringAgent steeringAgent) { var desiredVelocity = GetWanderForce(); desiredVelocity = desiredVelocity.normalized * steeringAgent.maxSpeed; steeringVelocity = desiredVelocity - velocity; steeringVelocity = Vector3.ClampMagnitude(steeringVelocity, steeringAgent.maxSteering); velocity = Vector3.ClampMagnitude(velocity + steeringVelocity, steeringAgent.maxSpeed); //transform.position += velocity * Time.deltaTime; transform.up = velocity.normalized; steeringVelocity = (desiredVelocity - steeringAgent.currentVelocity) * steeringAgent.wanderWeight; return(steeringVelocity); }
public override SteeringOutput CalculateSteering(SteeringAgent agent) { SteeringOutput output = new SteeringOutput(); Vector3 linearVelocity = (_target - agent.transform.position).normalized; if ((_target - agent.transform.position).sqrMagnitude > (_nearEnoughDist * _nearEnoughDist)) { linearVelocity *= agent.GetMaxLinearVelocity(); } else { linearVelocity *= 0.01f; } output.LinearVelocity = linearVelocity; return(output); }
private void Start() { _currentTypeBuster = TypeBuster.EMPTY; _audioSource = GetComponent <AudioSource>(); GameManagerOffline.S._players.Add(gameObject); _rigidbody = GetComponent <Rigidbody>(); _transform = GetComponent <Transform>(); _steeringAgent = GetComponent <SteeringAgent>(); _steering = SteeringJoystick; if (_steeringAgent == null) { GameManagerOffline.S._activateBusterLeft.onClick.AddListener(UsingCurrentBuster); GameManagerOffline.S._activateBusterRight.onClick.AddListener(UsingCurrentBuster); GameManagerOffline.S._activateImpactLeft.GetComponent <ButtonImpact>()._impact += UsingImpact; GameManagerOffline.S._activateImpactRight.GetComponent <ButtonImpact>()._impact += UsingImpact; GameManagerOffline.S._activateImpactLeft.GetComponent <ButtonImpact>()._beginImpact += ScaleRightHand; GameManagerOffline.S._activateImpactRight.GetComponent <ButtonImpact>()._beginImpact += ScaleRightHand; } }
public override SteeringOutput CalculateSteering(SteeringAgent agent) { Vector3 offset = agent.RigidB.velocity; offset.Normalize(); offset *= _offset; Vector3 circleOffset = new Vector3(Mathf.Cos(_wanderAngle) * _radius, 0f, Mathf.Sin(_wanderAngle) * _radius); _wanderAngle += Random.Range(0f, 1f) * _maxAngleChange - (_maxAngleChange * 0.5f); Vector3 newTarget = agent.transform.position + offset + circleOffset; SteeringOutput output = new SteeringOutput(); Vector3 linearVelocity = (newTarget - agent.transform.position).normalized; linearVelocity *= agent.GetMaxLinearVelocity(); output.LinearVelocity = linearVelocity; return(output); }
// Use this for initialization void Start() { steeringAgent = this.GetComponent <SteeringAgent>(); }
protected void characterStart(){ //script of same GameObject initiation seekScript = GetComponent<Seek> (); arriveScript = GetComponent<Arrive> (); steeringScript = GetComponent<SteeringAgent> (); alignScript = GetComponent<Align> (); ai = GetComponent<SorcererAI>(); playerNetworkScript = GetComponent<CharacterNetworkScript>(); basicAttackScript = GetComponent<BasicAttack> (); sphere = GameObject.CreatePrimitive (PrimitiveType.Sphere); sphere.renderer.castShadows = false; sphere.renderer.receiveShadows = false; sphere.transform.parent = transform; sphere.transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f); sphere.gameObject.layer = LayerMask.NameToLayer ("Minimap"); accuracy = 0.8f; attacking = false; stopMoving (); }
// Use this for initialization protected virtual void Start() { graph = GetComponent<Graph> (); agent = GetComponent<SteeringAgent> (); seekScript = GetComponent<Seek> (); arriveScript = GetComponent<Arrive> (); characterNode = GetComponent<Node> (); openList = new List<Node>(); closedList = new List<Node>(); path = new List<Node> (); pathIndex = 0; DontDestroyOnLoad (gameObject); }
void Awake(){ agent = GameObject.FindObjectOfType(typeof(SteeringAgent))as SteeringAgent; agent.ResetVelocities(); }
public abstract Vector3 UpdateBehaviour(SteeringAgent steeringAgent);
// Use this for initialization void Awake () { hault = false; agent = GetComponent<SteeringAgent> (); }
void Start() { steeringScript = gameObject.GetComponent<SteeringAgent> (); target = steeringScript.targetPosition; }
public abstract SteeringOutput CalculateSteering(SteeringAgent agent);
public AgentInput(SteeringAgent agent) { this.agent = agent; }
public SteeringBehavior(SteeringAgent agent) { this.agent = agent; }
public override ISteeringBehaviour CreateInstance(SteeringAgent agent) { return(new ObstacleAvoidance(agent, this)); }
public override ISteeringBehaviour CreateInstance(SteeringAgent agent) { return new Cohesion(agent, this); }
public virtual void Init(SteeringAgent agent) { steeringAgent = agent; }
public override ISteeringBehaviour CreateInstance(SteeringAgent agent) { return(new Separation(agent, this)); }
public Cohesion(SteeringAgent agent, CohesionData data) : base(agent, data) { }
// Update is called once per frame public virtual SteeringOutput CalculateSteering(SteeringAgent agent) { SteeringOutput steering = new SteeringOutput(); return(steering); }
public ObstacleAvoidance(SteeringAgent agent, ObstacleAvoidanceData data) : base(agent, data) { }
public void Init(SteeringAgent agent, SteeringController steering, RigidbodyMovementController controller) { this.agent = agent; this.steering = steering; this.controller = controller; }
public Separation(SteeringAgent agent, SeparationData data) : base(agent, data) { }
void Start() { agent = GetComponent <SteeringAgent>(); agent.RegisterSteeringBehaviour(this); }
void Awake() { steeringAgent = GetComponent<SteeringAgent>(); steeringSeek = GetComponent<Seek>(); steeringArrive = GetComponent<Arrive>(); //steeringFlee = GetComponent<SteeringFlee>(); //steeringWander = GetComponent<SteeringWander>(); steeringAgent.enabled = true; //Wander(); InitBT(); bt.Start(); }
void Start() { mAgent = GetComponent <SteeringAgent>(); mCurrentMode = mNPCMode; ChangeMode(); }
public abstract ISteeringBehaviour CreateInstance(SteeringAgent agent);