private void GoToHive(float dt) { Vector3 position = transform.position; position = Vector3.MoveTowards(position, _hive.transform.position, PollenBehaviorData.GoToHiveSpeed * dt); Movement2D.Teleport(position); }
private void FollowPlayer(float dt) { Vector3 position = transform.position; position = Vector3.MoveTowards(position, _followPlayer.PollenTarget.position, PollenBehaviorData.FollowPlayerSpeed * dt); Movement2D.Teleport(position); }
protected override void PhysicsUpdate(float dt) { if (!CanMove) { return; } if (!PlayerBehaviorData.AllowAirControl && IsFalling) { return; } Vector3 velocity = MoveDirection * PlayerBehaviorData.MoveSpeed; if (Movement2D.IsKinematic) { Movement2D.Teleport(Movement2D.Position + velocity * dt); } else { velocity.y = Movement2D.Velocity.y; Movement2D.Velocity = velocity; } base.PhysicsUpdate(dt); }
public override void OnSpawn(SpawnPoint spawnpoint) { base.OnSpawn(spawnpoint); WaspSpawnPoint waspSpawnPoint = spawnpoint.GetComponent <WaspSpawnPoint>(); _armorToAttack = waspSpawnPoint.ArmorToAttack; _splineYOffset = PartyParrotManager.Instance.Random.NextSingle(-waspSpawnPoint.Offset, waspSpawnPoint.Offset); // init our spline state _spline = waspSpawnPoint.GetComponent <BezierSpline>(); _splineLength = _spline.EstimatedLength(); _splinePosition = 0.0f; // teleport to our starting position // setting the behavior's Position doesn't seem to immediately warp // so falling back on just forcing the transform position to move :( Vector3 targetPosition = _spline.GetPoint(0.0f); targetPosition.y += _splineYOffset; Movement2D.Teleport(targetPosition); if (null != AnimationHelper) { AnimationHelper.SetFacing(Vector3.zero - transform.position); } SetState(WaspState.FollowingSpline); }
private void Float(float dt) { // recycle if we're off the screen Vector3 position = transform.position; if (position.y - Pollen.Height / 2.0f > GameStateManager.Instance.GameManager.GameData.ViewportSize) { Pollen.Recycle(); return; } position.y += PollenBehaviorData.FloatSpeed * dt; Movement2D.Teleport(position); }
protected override void PhysicsUpdate(float dt) { base.PhysicsUpdate(dt); if (!CanMove || WaspState.FollowingSpline != _state) { return; } _splinePosition += WaspBehaviorData.MoveSpeed * dt; float t = _splinePosition / _splineLength; Vector3 targetPosition = _spline.GetPoint(t); targetPosition.y += _splineYOffset; Movement2D.Teleport(targetPosition); }