// Update is called once per frame void Update() { Vector3 accel = steeringBasics.interpose(target1, target2); steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame void Update() { Vector3 accel = wander.GetSteering(); steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame private void Update() { var accel = GetSteering(); _steeringBasics.Steer(accel); _steeringBasics.LookWhereYoureGoing(); }
void Update() { Vector3 accel = evade.GetSteering(target); steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame void Update() { Vector3 accel = steeringBasics.seek(target.position); steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame void Update() { Vector3 accel = steeringBasics.Arrive(targetPosition); steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
void Update() { // 得到线性加速度 Vector3 accel = flee.getSteering(target.position); // 设置刚体速度 steeringBasics.Steer(accel); // 设置朝向 steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame void Update() { // 得到 线性加速度 Vector3 accel = pursue.getSteering(target); // 设置刚体速度 steeringBasics.Steer(accel); // 朝向 steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame private void FixedUpdate() { var accel = Vector3.zero; accel += _cohesion.GetSteering(_sensor.Targets) * CohesionWeight; accel += _separation.GetSteering(_sensor.Targets) * SeparationWeight; accel += _wander.GetSteering(); _steeringBasics.Steer(accel); _steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame private void FixedUpdate() { if (IsWanderingTarget == false) { return; } var accel = GetSteering(); _steeringBasics.Steer(accel); _steeringBasics.LookWhereYoureGoing(); }
private void FixedUpdate() { if (IsEvadingTarget == false || Target == null) { return; } var accel = GetSteering(Target); _steeringBasics.Steer(accel); _steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame private void FixedUpdate() { if (AvoidingWallAllTheTime == false) { return; } var accel = GetSteering(); _steeringBasics.Steer(accel); _steeringBasics.LookWhereYoureGoing(); }
/// <summary> /// returns true while still following a path. Returns false when it arrives /// </summary> /// <returns></returns> public bool DoFollowPathStep() { RequestPath(GetTarget().transform); var followingPath = true; var pos2D = Path.Vector3ToVector2(_myTransform.position); if (_path == null) // we are still waiting for the path to be calculated { return(true); // we are technically still following the path (we have not arrived) } if (_pathIndex > _path.TurnBoundaries.Length || _path.FinishLineIndex == -1) { _pathIndex = 0; return(true); } // loops through the turn boundaries till it founds the last boundary it has crossed. // This solves the pathing problem if we move through several turn boundaries for each turn. while (_path.TurnBoundaries[_pathIndex].HasCrossedLine(pos2D)) { // we arrived at the end of the path if (_pathIndex >= _path.FinishLineIndex) { break; } _pathIndex++; } if (Vector3.Distance(transform.position, GetTarget().position) < 1f) { GetComponent <Rigidbody>().velocity = Vector3.zero; followingPath = false; } // rotate and move the unit to the next point if (followingPath) { var acc = _arrive.GetSteering(_path.LookPoints[_pathIndex]); if (Math.Abs(acc.x) < 0.01f && Math.Abs(acc.z) < 0.01f) // something went wrong with the pathfinding and we are stuck. Do a new plan. { if (GetTarget() != null) { RequestPath(GetTarget().transform, true); } } _steering.Steer(acc); _steering.LookWhereYoureGoing(); } return(followingPath); }
// Update is called once per frame void Update() { // 加速度(有碰撞 就避免碰撞) Vector3 accel = colAvoid.GetSteering(colAvoidSensor.targets); // 没有任何碰撞的时候就 漫游 if (accel.magnitude < 0.005f) { accel = wander.GetSteering(); } // 速度 steeringBasics.Steer(accel); // 朝向 steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame private void Update() { //get the best hidePosition var hideAccel = GetSteering(Target, Objs, out var hidePosition); //make sure we avoid the walls when we move to the hidding spot var accel = _wallAvoid.GetSteering(hidePosition - transform.position); //if the acceleration from the wall avoidance is too small we use the one returned by out Hide behavior if (accel.magnitude < 0.005f) { accel = hideAccel; } _steeringBasics.Steer(accel); _steeringBasics.LookWhereYoureGoing(); }
void Update() { path.draw(); // 执行原路返回的逻辑 if (reversePath && isAtEndOfPath()) { path.reversePath(); } // 计算线性加速度 Vector3 accel = followPath.getSteering(path, pathLoop); // 设置刚体速度 steeringBasics.Steer(accel); // 朝向 steeringBasics.LookWhereYoureGoing(); }
void Update() { // 得到加速度 躲在障碍物后面,同时不被目标看到 Vector3 hidePosition; Vector3 hideAccel = hide.GetSteering(target, obstacleSpawner.objs, out hidePosition); // 如果撞墙要 解决 Vector3 accel = wallAvoid.GetSteering(hidePosition - transform.position); // 没有撞墙 (说明如果撞墙先解决撞墙) if (accel.magnitude < 0.005f) { accel = hideAccel; } // 设置速度 和 朝向 steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
void LateUpdate() { Vector3 targetPos; // 偏移追随加速度 和 分隔加速度 Vector3 offsetAccel = offsetPursuit.getSteering(target, offset, out targetPos); Vector3 sepAccel = separation.GetSteering(sensor.targets); // 速度会 受到两个方面的影响 steeringBasics.Steer(offsetAccel + sepAccel); /* 如果我们还在前往,那就要朝向我们要去的地方,其他的方向和我们的形成目标是一样的 */ if (Vector3.Distance(transform.position, targetPos) > groupLookDist) { steeringBasics.LookWhereYoureGoing(); } else { steeringBasics.lookAtDirection(target.rotation); } }
// Update is called once per frame void Update() { Vector3 accel = Vector3.zero; // 集群加速度 accel += cohesion.GetSteering(sensor.targets) * cohesionWeight; // 分隔加速度 accel += separation.GetSteering(sensor.targets) * separationWeight; // 速度匹配加速度 accel += velocityMatch.GetSteering(sensor.targets) * velocityMatchWeight; // 如果没有那些 影响, 就漫游好了 if (accel.magnitude < 0.005f) { accel = wander.GetSteering(); } // 设置刚体速度 和 朝向 steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
void Update() { // 调试 path.draw(); // 是否原路返回 if (isAtEndOfPath()) { path.reversePath(); } // 躲避 加速度 Vector3 accel = colAvoid.GetSteering(colAvoidSensor.targets); // 不需要躲避 就沿着路径走 if (accel.magnitude < 0.005f) { accel = followPath.getSteering(path); } // 设置刚体速度 和 朝向 steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); }
// Update is called once per frame void Update() { // 到达终点了, 原路返回 if (isAtEndOfPath()) { path.reversePath(); } // 得到加速度 (要躲避墙) Vector3 accel = wallAvoidance.GetSteering(); // 沿着路径走了 (约定没有碰撞时 加速度为0了) if (accel.magnitude < 0.005f) { accel = followPath.getSteering(path); } // 设置刚体 和 朝向 steeringBasics.Steer(accel); steeringBasics.LookWhereYoureGoing(); // 调试 path.draw(); }