public void Spawn(Weapon weapon, Agent shooter, Vector3 targetPosition) { var heightOffset = Vector3.up * 0.3f; // raise up to shoot over low walls Spawn(weapon, shooter, shooter.Kinematic.Position + heightOffset, targetPosition, Parameters.Instance.RocketDamage); name = "ROCKET_" + id; EntityType = EntityTypes.Rocket; IsAiControlled = true; Kinematic.MaximumSpeed = Parameters.Instance.RocketMaximumSpeed; var directionToTarget = (targetPosition - (shooter.Kinematic.Position + heightOffset)).normalized; var transform1 = transform; transform1.position = shooter.Kinematic.Position + heightOffset + directionToTarget * shooter.Kinematic.Radius; transform1.localScale = new Vector3(0.25f, 0.5f, 0.25f); transform.LookAt(targetPosition); transform.Rotate(Vector3.right, 90); if (Parameters.Instance.RocketIsHeatSeeking) { SteeringBehaviours.Add(new Seek(Kinematic, shooter.TargetingSystem.Target.Kinematic)); } else { Kinematic.SetVelocity(directionToTarget * Parameters.Instance.RocketMaximumSpeed); } }
public override void CheckCondition(MobInfo data) { if (m_fCurrentTime > m_fIdleTime && SteeringBehaviours.CreatRandomTarget(data) == true) { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_NoPlayerWander); } if (data.m_Player != null && data.m_Player.IsDead == false) { AnimatorStateInfo info = data.m_AnimationController.Animator.GetCurrentAnimatorStateInfo(0); if (info.IsName("WanderIdle2")) { if (info.normalizedTime > m_AnimatorLeaveTime) { if ((data.m_Player.transform.position - data.m_Go.transform.position).magnitude > data.m_fAttackRange) { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_Chase); } else { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_Dodge); } } } } }
void ComputerForces() { // SET force to zero Vector3 force = Vector3.zero; //FOR i = 0 to behaviours Count for (int i = 0; i < behaviours.Length; i++) { SteeringBehaviours behaviour = behaviours[1]; //IF behaviour is not enabled if (!behaviour.enabled) { //Continue continue; } //SET fore to force + bahaviour's force force += behaviour.GetForce(); //IF force is greater than max Velcity if (force.magnitude > maxVeocity) { //SET force to force normalized x maxVelocity force = force.normalized * maxVeocity; //BREAK break; } } }
void Update() { velocity += SteeringBehaviours.Arrive(this, target, 3f); Vector3 offset = centro.position - transform.position; float sqrLen = offset.sqrMagnitude; if (transform.position.x > centro.position.x + 4 || transform.position.x < centro.position.x - 4 || transform.position.y > centro.position.y + 2 || transform.position.y < centro.position.y - 2) { velocity += SteeringBehaviours.Arrive(this, centro, 3f); velocity += SteeringBehaviours.inside(this, target, 999f); print("fuera"); } else { print("dentro"); } //velocity += SteeringBehaviours.Inside(this, 3f, centro); transform.position += velocity * Time.deltaTime; }
// Use this for initialization void Start() { MaximumHealth = Health; Parent = GetComponentInParent <StateObject>(); SB = GetComponent <SteeringBehaviours>(); gameObject.tag = "Vehicle"; }
void Update() { velocity += SteeringBehaviours.Arrive(this, target, 3); velocity += SteeringBehaviours.Flee(this, target2, 1); velocity += SteeringBehaviours.Separate(this, GameManager.agents, 2f); transform.position += velocity * Time.deltaTime; }
public override void CheckCondition(MobInfo data) { if (m_fCurrentTime > m_fIdleTime && SteeringBehaviours.CreatRandomTarget(data) == true) { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_Wander); } if (data.m_Player != null && data.m_Player.IsDead == false) { float Dist = (data.m_Player.transform.position - data.m_Go.transform.position).magnitude; if (Dist < data.m_fPatrolVisionLength) { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_Flee); } AnimatorStateInfo info = data.m_AnimationController.Animator.GetCurrentAnimatorStateInfo(0); if (info.IsName("WanderIdle")) { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_ChaseToRemoteAttack); if (info.normalizedTime > m_AnimatorLeaveTime) { data.m_FSMSystem.PerformTransition(eFSMTransition.Go_Chase); } } } }
public override Vector2 Calculate() { bool IsNear(BaseGameEntity entity, float range) => Vector2.DistanceSquared(this.Entity.Position, entity.Position) < range * range; bool InAlignmentRange(MovingEntity entity) => IsNear(entity, this.alignmentRadius); bool InCohesionRange(MovingEntity entity) => IsNear(entity, this.cohesionRadius); bool InSeparationRange(MovingEntity entity) => IsNear(entity, this.separationRadius); const int amountOfNeighbours = 10; IEnumerable <Bird> birds = this.world.Entities.OfType <Bird>() .OrderBy(bird => Vector2.DistanceSquared(bird.Position, this.Entity.Position)) .Where(entity => entity != this.Entity) .Take(amountOfNeighbours) .ToArray(); // When no neighbours nearby, wander if (!birds.Any()) { return(this.innerWander.Calculate()); } Vector2 alignment = SteeringBehaviours.Alignment(birds.Where(InAlignmentRange)); Vector2 cohesion = SteeringBehaviours.Cohesion(this.Entity, birds.Where(InCohesionRange)); Vector2 separation = SteeringBehaviours.Separation(this.Entity, birds.Where(InSeparationRange)); Vector2 target = alignment * this.alignmentWeight + cohesion * this.cohesionWeight + separation * this.separationWeight; return(target * this.Strength); }
void Update() { velocity += SteeringBehaviours.Arrive(this, target, 3); //velocity += SteeringBehaviours.Flee(this, target2, 1); transform.position += velocity * Time.deltaTime; velocity += SteeringBehaviours.Seek(this, target, 1f); }
void IPooledObject.OnSpawn() { meshRenderer = GetComponent <MeshRenderer>(); col = GetComponent <Collider>(); rb = GetComponent <Rigidbody>(); steering = GetComponentInChildren <SteeringBehaviours>(); soundManager = AudioVolumeManager.GetInstance(); audioSource = GetComponent <AudioSource>(); audioSource.volume = soundManager.SoundEffectVolume; audioSource.pitch = Random.Range(0.8f, 1.4f); audioSource.PlayOneShot(ejecting); meshRenderer.enabled = true; col.enabled = true; rb.useGravity = true; steering.PursuitOff(); impact.Stop(); travelTrail.Stop(); timer = 0.0f; float xForce = Mathf.Sign(Random.Range(-1, 1f)) * horizontalForce; float yForce = Random.Range(-verticalForce, verticalForce); float zForce = Random.Range(-verticalForce / 1.2f, verticalForce / 5); Vector3 force = new Vector3(xForce, yForce, zForce); rb.AddForce(force, ForceMode.Impulse); transform.rotation = Quaternion.LookRotation(Vector3.RotateTowards(transform.forward, rb.velocity, 500, 0.0F)); }
protected override void Start() { base.Start(); SetupTarget(); _steeringBehaviours = new SteeringBehaviours(Boid); }
void Update() { //velocity += SteeringBehaviours.InsideCircle(this,target,target2,3); esto de aqui hace que funcione el circulo velocity += SteeringBehaviours.InsideRectangle(this, target, target2, 2, 2);// esto hace que funcione el cuadrado transform.position += velocity * Time.deltaTime; }
private void Start() { meshRenderer = GetComponent <MeshRenderer>(); col = GetComponent <Collider>(); rb = GetComponent <Rigidbody>(); steering = GetComponentInChildren <SteeringBehaviours>(); soundManager = AudioVolumeManager.GetInstance(); }
// Update is called once per frame void Update() { velocity += SteeringBehaviours.Seek(this, target.transform); velocity += SteeringBehaviours.Separate(this, targets, 4f); transform.position += velocity * Time.deltaTime; }
void Start() { managerState = GetComponentInChildren <State_Manager>(); currentState = new State_Patrol(); SB = GetComponent <SteeringBehaviours>(); CurrentHP = MaxHP; currentAmmo = maxAmmo; FindNearestHP(); }
public override void Do(MobInfo data) { data.navMeshAgent.enabled = true; data.m_vTarget = data.m_Player.transform.position; SteeringBehaviours.NavMove(data); Vector3 v = (SteeringBehaviours.GroupBehavior(data, 60, true) + SteeringBehaviours.GroupBehavior(data, 60, false)) * 2f * Time.deltaTime; data.m_Go.transform.position += v; }
public override Vector2 Calculate() { this.currentOffset += this.random.Next(-100, 100) / 100f * 3f; // .Next() is exclusive this.currentOffset = Math.Min(this.currentOffset, this.range); this.currentOffset = Math.Max(this.currentOffset, -this.range); Vector2 target = SteeringBehaviours.Wander(this.Entity, this.currentOffset); return(target); }
void Update() { velocity += SteeringBehaviours.Arrive(this, target, 3); velocity += SteeringBehaviours.EnCirculo(this, target, target2, 4.4f); velocity += SteeringBehaviours.ElCuadrado(this, target, target2, 2, 2); transform.position += velocity * Time.deltaTime; }
void Update() { if (transform.position.x > areaCubo || transform.position.x < -areaCubo || transform.position.y > areaCubo || transform.position.y < -areaCubo) { velocity += SteeringBehaviours.Seek(this, Originpoint, 100); transform.position += velocity * Time.deltaTime; } velocity += SteeringBehaviours.Seek(this, target, 100); transform.position += velocity * Time.deltaTime; }
public void Execute(Entity entity, int index, ref Translation translation, ref SteeringComponent steeringComponent, ref LocalToWorld localToWorld, ref AiAgentComponent aiAgent, ref GoalComponent goalComponent) { var nodes = Routes[entity]; if (nodes.Length <= 1) { return; } const float seekForce = .0025f; const float wAvoidForce = .05f; const float oAvoidForce = .0075f; const float wanderForce = .0075f; const float maxSpeed = .1f; var currentVelocity = new Vector3(steeringComponent.Velocity.x, steeringComponent.Velocity.y, steeringComponent.Velocity.z); var target = new Vector3(nodes[aiAgent.NavigationIndex].Node.x, 1, nodes[aiAgent.NavigationIndex].Node.z); var location = new Vector3(localToWorld.Position.x, 1, localToWorld.Position.z); var steering = Vector3.zero; if (goalComponent.Behaviour.Seek) { steering += SteeringBehaviours.Seek(currentVelocity, location, target, maxSpeed, seekForce); } if (goalComponent.Behaviour.EnableWallAvoidance) { steering += SteeringBehaviours.WallAvoidance(currentVelocity, translation.Value, maxSpeed, wAvoidForce, 2.0f, World); } if (goalComponent.Behaviour.EnableObjectAvoidance) { steering += SteeringBehaviours.ObstacleAvoidance(currentVelocity, translation.Value, oAvoidForce, 3.0f, World); } if (goalComponent.Behaviour.Wander) { steering += SteeringBehaviours.Wander(currentVelocity, location, maxSpeed, 25f, 25f, .1f, wanderForce); } var newDirection = Vector3.ClampMagnitude(currentVelocity + steering, maxSpeed); if (Vector3.Distance(target, location) <= .5f) { var destinationReached = aiAgent.DestinationReached || aiAgent.NavigationIndex + 1 >= nodes.Length; EntityCommandBuffer.SetComponent(index, entity, new AiAgentComponent { NavigationIndex = aiAgent.NavigationIndex + 1, DeferredFrames = aiAgent.DeferredFrames, DestinationReached = destinationReached, NavigationTotal = aiAgent.NavigationTotal }); } EntityCommandBuffer.SetComponent(index, entity, new SteeringComponent { Velocity = new float3(newDirection.x, newDirection.y, newDirection.z) }); }
////////////////////////////////////////////////////////////////////////////////////////// #region Runtime ////////////////////////////////////////////////////////////////////////////////////////// // Use this for initialization void Start() { m_steering = this.GetComponent <SteeringBehaviours>(); if (m_collisionObserver) { m_collisionListener = createCollisionListener(); Observer <CollisionObserver> observer = m_collisionObserver.getObserver(); observer.add(m_collisionListener); } }
// Use this for initialization void Start() { stopMovement(); m_steering = this.GetComponent <SteeringBehaviours>(); if (m_steering) { m_entityVision = m_steering.getEntityVision(); m_wanderTimer = m_delayBeforePursue; } }
void Update() { velocity += SteeringBehaviours.Seek(this, target, 2); //Quede dentro de un circulo //velocity += SteeringBehaviours.Circle(this, target, center, 2); //quede dentro de un cuadrado velocity += SteeringBehaviours.Rectangle(this, target, center, 2, 2); transform.position += velocity * Time.deltaTime; }
void Update() { velocity += SteeringBehaviours.Seek(this, Target.targetsAB[indexTarget], 10); transform.position += velocity * Time.deltaTime; if (Vector3.Distance(transform.position, target.position) <= 0.5f) { NextTarget(); } }
public MovingEntity(Vector2D position, World world) : base(position, world) { SteeringBehaviours = new SteeringBehaviours(this); HashTagLifeGoal = null; PathPlanner = new PathPlanner(this); Energy = 100; Hunger = 0; SteeringBehaviours.ObstacleAvoidanceOn(1.0); }
public override void Do(MobInfo data) { vec = data.m_Go.transform.forward; vec += data.m_Go.transform.position; vec.y += 0.5f; GO.transform.position = vec; data.m_vTarget = data.m_Go.transform.position + (data.m_Go.transform.position - data.m_Player.transform.position).normalized; data.m_vTarget.y = data.m_Go.transform.position.y; SteeringBehaviours.NavMove(data); }
void Update() { velocity += SteeringBehaviours.Arrive(this, target, 3f); //velocity += SteeringBehaviours.Flee(this, target, 1f); //velocity += 0.5f * SteeringBehaviours.Separate(this, GameManager.agents, 0.5f); //velocity += SteeringBehaviours.Seek(this, target, 1f); SteeringBehaviours.KeepInCircleArea(getTrans, new Vector3(0, 0, 0), 1.5f); //SteeringBehaviours.KeepInRectangleArea(getTrans, new Rect(0,0,7f,5f)); transform.position += velocity * Time.deltaTime; }
void Update() { if (Vector3.Distance(Originpoint.position, transform.position) > 2) { velocity += SteeringBehaviours.Seek(this, Originpoint, 100); transform.position += velocity * Time.deltaTime; } velocity += SteeringBehaviours.Seek(this, target, 100); transform.position += velocity * Time.deltaTime; }
// Update is called once per frame void Update() { velocity += SteeringBehaviours.Separate(this, SpawnManager.GO, 3f); velocity += SteeringBehaviours.Seek(this, Waypoints.points[wavePointIndex]); transform.position += velocity * Time.deltaTime; if (Vector3.Distance(transform.position, target.position) <= 0.2f) { GoNextPoint(); } }
private void Update() { float distance = (transform.position - centerRect).magnitude; target = GameObject.Find("Target").GetComponent <Transform>(); targetPosition = target.transform.position; //velocity += SteeringBehaviours.Seek(this, target); velocity += SteeringBehaviours.InsideRectangle(this, targetPosition, centerRect, rectangleWidth, rectangleHeight) * Time.deltaTime; transform.position += velocity * Time.deltaTime; }
void Update() { float actualDistancia = Vector2.Distance(center, position); velocity += SteeringBehaviours.Arrive(this, target, 1f); velocity += SteeringBehaviours.Seek(this, target, 1); //velocity += SteeringBehaviours.Flee(this, target2,1); //velocity += SteeringBehaviours.Separate(this, GameManager.agents, 2f); transform.position += velocity * Time.deltaTime; }
public static Vector3 Arrive(SteeringActor actor, Vector3 targetPos, SteeringBehaviours.Deceleration deceleration) { SteeringBehaviours.Forces attributes = actor.GetAttributes().Forces; Vector3 toTarget = targetPos - actor.GetPosition(); float dist = toTarget.magnitude; if (dist <= 0) { return new Vector3(); } float decelerationTweaker = 0.3f; float speed = dist / ((float)deceleration * decelerationTweaker); speed = Mathf.Min(speed, attributes.MaxSpeed); Vector3 desiredVelocity = toTarget * speed / dist; return desiredVelocity;// - GetVelocity(); }
void Awake() { m_SteeringBehaviours = GetComponent<SteeringBehaviours>(); }
// Use this for initialization void Start() { steering = new SteeringBehaviours(this); rb = GetComponent<Rigidbody>(); }