public override void Update(IUpdateArgs args) { if (CanRender) { var knownPos = KnownPosition.ToVector3(); // var bb = base.BoundingBox; // var knownPos = bb.GetCenter(); if (DoRotation) { //var offset = new Vector3((float) Width, (float) Height, (float) Width) / 2f; var offset = new Vector3(0.5f, 0f, 0.5f); ItemRenderer.Update(args, MCMatrix.CreateScale(0.25f) * MCMatrix.CreateTranslation(-offset) * MCMatrix.CreateRotationY(MathHelper.ToRadians(_rotation)) * MCMatrix.CreateTranslation(offset) * MCMatrix.CreateTranslation(knownPos)); } else { ItemRenderer.Update(args, MCMatrix.CreateScale(0.25f) * MCMatrix.CreateRotationY(MathHelper.ToRadians(KnownPosition.Yaw)) * MCMatrix.CreateTranslation(knownPos)); } } if (DoRotation) { _rotation += 45f * (float)args.GameTime.ElapsedGameTime.TotalSeconds; } }
public override void Update(IUpdateArgs args) { if (CanRender) { var offset = new Vector3(0.5f, 0.5f, 0.5f); if (DoRotation) { ItemRenderer.Update(args, Matrix.Identity * Matrix.CreateScale(Scale) * Matrix.CreateTranslation(-offset) * Matrix.CreateRotationY(MathHelper.ToRadians(_rotation)) * Matrix.CreateTranslation(offset) * Matrix.CreateTranslation((KnownPosition.ToVector3())), Color.White.ToVector3(), KnownPosition); } else { ItemRenderer.Update(args, Matrix.Identity * Matrix.CreateScale(Scale) * Matrix.CreateRotationY(MathHelper.ToRadians(KnownPosition.Yaw)) * Matrix.CreateTranslation(KnownPosition.ToVector3()), Color.White.ToVector3(), KnownPosition); } ItemRenderer?.Update(args.GraphicsDevice, args.Camera); } if (DoRotation) { _rotation += 45f * (float)args.GameTime.ElapsedGameTime.TotalSeconds; } }
private Vector3 GetAdjustedLengthFromCollision(Vector3 velocity) { var length = Length / 2; var direction = Vector3.Normalize(Velocity * 1.00000101f); var position = KnownPosition.ToVector3(); int count = (int)(Math.Ceiling(Velocity.Length() / length) + 2); for (int i = 0; i < count; i++) { var distVec = direction * (float)length * i; BlockCoordinates blockPos = position + distVec; Block block = Level.GetBlock(blockPos); if (block.IsSolid) { Ray ray = new Ray(position, direction); var distance = ray.Intersects(block.GetBoundingBox()); if (distance.HasValue) { float dist = (float)((float)distance - (Length / 4)); return(ray.Direction * new Vector3(dist)); } } } return(velocity); }
/// <summary> /// For debugging of flight-path and rotation. /// </summary> private void BroadcastMoveAndMotion() { if (new Random().Next(5) == 0) { McpeSetEntityMotion motions = McpeSetEntityMotion.CreateObject(); motions.runtimeEntityId = EntityId; motions.velocity = Velocity; //new Task(() => Level.RelayBroadcast(motions)).Start(); Level.RelayBroadcast(motions); } McpeMoveEntity moveEntity = McpeMoveEntity.CreateObject(); moveEntity.runtimeEntityId = EntityId; moveEntity.position = KnownPosition; Level.RelayBroadcast(moveEntity); if (Shooter != null && IsCritical) { var p = Shooter as Player; if (p != null) { var particle = new CriticalParticle(Level); particle.Position = KnownPosition.ToVector3(); particle.Spawn(new[] { p }); } } }
public override void OnTick() { TimeToLive--; if (TimeToLive <= 0) { DespawnEntity(null); return; } var players = Level.GetOnlinePlayers; foreach (var player in players) { if (KnownPosition.DistanceTo(player.KnownPosition) <= 1.8) { player.Inventory.AddItem(Item.ItemId, Item.MetaData); DespawnEntity(player); break; } new EntityTeleport(player.Wrapper) { UniqueServerId = EntityId, Coordinates = KnownPosition.ToVector3(), Yaw = (byte)KnownPosition.Yaw, Pitch = (byte)KnownPosition.Pitch, OnGround = true }.Write(); } }
/// <summary> /// For debugging of flight-path and rotation. /// </summary> private void BroadcastMoveAndMotion() { if (new Random().Next(5) == 0) { McpeSetEntityMotion motions = McpeSetEntityMotion.CreateObject(); motions.runtimeEntityId = EntityId; motions.velocity = Velocity; Level.RelayBroadcast(motions); } if (LastSentPosition != null) { McpeMoveEntityDelta move = McpeMoveEntityDelta.CreateObject(); move.runtimeEntityId = EntityId; move.prevSentPosition = LastSentPosition; move.currentPosition = (PlayerLocation)KnownPosition.Clone(); move.isOnGround = IsWalker && IsOnGround; if (move.SetFlags()) { Level.RelayBroadcast(move); } } LastSentPosition = (PlayerLocation)KnownPosition.Clone(); // Used for delta if (Shooter != null && IsCritical) { var particle = new CriticalParticle(Level); particle.Position = KnownPosition.ToVector3(); particle.Spawn(new[] { Shooter }); } }
public override void Update(IUpdateArgs args) { if (CanRender) { ItemRenderer?.Update( Matrix.Identity * Matrix.CreateScale(Scale) * Matrix.CreateRotationY(MathHelper.ToRadians(KnownPosition.Yaw)) * Matrix.CreateTranslation(KnownPosition.ToVector3()), KnownPosition); ItemRenderer?.Update(args.GraphicsDevice, args.Camera); } }
private void BroadcastMoveAndMotion() { foreach (var i in Level.OnlinePlayers) { new EntityTeleport(i.Wrapper) { UniqueServerID = EntityId, Coordinates = KnownPosition.ToVector3(), Yaw = (byte)KnownPosition.Yaw, Pitch = (byte)KnownPosition.Pitch, OnGround = true }.Write(); } }
private void BroadcastMoveAndMotion() { foreach (var i in Level.GetOnlinePlayers) { new EntityTeleport(i.Wrapper) { UniqueServerId = EntityId, Coordinates = KnownPosition.ToVector3(), Yaw = KnownPosition.Yaw, Pitch = KnownPosition.Pitch, OnGround = false }.Write(); new EntityVelocity(i.Wrapper) { EntityId = EntityId, VelocityX = (short)Velocity.X, VelocityY = (short)Velocity.Y, VelocityZ = (short)Velocity.Z }.Write(); } }
public override void OnTick() { base.OnTick(); if (KnownPosition.Y <= 0 || (Velocity.Distance <= 0 && DespawnOnImpact) || (Velocity.Distance <= 0 && !DespawnOnImpact && Ttl <= 0)) { DespawnEntity(); return; } Ttl--; if (KnownPosition.Y <= 0 || Velocity.Distance <= 0) { return; } Entity entityCollided = CheckEntityCollide(KnownPosition.ToVector3(), Velocity); bool collided = false; if (entityCollided != null) { double speed = Math.Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y + Velocity.Z * Velocity.Z); double damage = Math.Ceiling(speed * Damage); if (IsCritical) { damage += Level.Random.Next((int)(damage / 2 + 2)); McpeAnimate animate = McpeAnimate.CreateObject(); animate.entityId = entityCollided.EntityId; animate.actionId = 4; Level.RelayBroadcast(animate); } Player player = entityCollided as Player; if (player != null) { damage = player.CalculatePlayerDamage(player, damage); } entityCollided.HealthManager.TakeHit(this, (int)damage, DamageCause.Projectile); entityCollided.HealthManager.LastDamageSource = Shooter; collided = true; } else { var velocity2 = Velocity; velocity2 *= (1.0d - Drag); velocity2 -= new Vector3(0, Gravity, 0); double distance = velocity2.Distance; velocity2 = velocity2.Normalize() / 2; for (int i = 0; i < Math.Ceiling(distance) * 2; i++) { PlayerLocation nextPos = (PlayerLocation)KnownPosition.Clone(); nextPos.X += (float)velocity2.X * i; nextPos.Y += (float)velocity2.Y * i; nextPos.Z += (float)velocity2.Z * i; BlockCoordinates coord = new BlockCoordinates(nextPos); Block block = Level.GetBlock(coord); collided = block.Id != 0 && (block.GetBoundingBox()).Contains(nextPos.ToVector3()); if (collided) { SetIntersectLocation(block.GetBoundingBox(), KnownPosition); break; } } } if (collided) { Velocity = Vector3.Zero; } else { KnownPosition.X += (float)Velocity.X; KnownPosition.Y += (float)Velocity.Y; KnownPosition.Z += (float)Velocity.Z; Velocity *= (1.0 - Drag); Velocity -= new Vector3(0, Gravity, 0); KnownPosition.Yaw = (float)Velocity.GetYaw(); KnownPosition.Pitch = (float)Velocity.GetPitch(); } // For debugging of flight-path if (BroadcastMovement) { BroadcastMoveAndMotion(); } }
public override void OnTick(Entity[] entities) { //base.OnTick(); if (KnownPosition.Y <= 0 || (Velocity.Length() <= 0 && DespawnOnImpact) || (Velocity.Length() <= 0 && !DespawnOnImpact && Ttl <= 0)) { if (DespawnOnImpact || (!DespawnOnImpact && Ttl <= 0)) { DespawnEntity(); return; } else { IsCritical = false; } return; } Ttl--; if (KnownPosition.Y <= 0 || Velocity.Length() <= 0) { return; } Entity entityCollided = CheckEntityCollide(KnownPosition, Velocity); bool collided = false; if (entityCollided != null) { if (OnEntityColission(entityCollided)) { double speed = Math.Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y + Velocity.Z * Velocity.Z); double damage = Math.Ceiling(speed * Damage); if (IsCritical) { damage += Level.Random.Next((int)(damage / 2 + 2)); McpeAnimate animate = McpeAnimate.CreateObject(); animate.runtimeEntityId = entityCollided.EntityId; animate.actionId = 4; Level.RelayBroadcast(animate); } if (PowerLevel > 0) { damage = damage + ((PowerLevel + 1) * 0.25); } Player player = entityCollided as Player; if (player != null) { damage = player.DamageCalculator.CalculatePlayerDamage(this, player, null, damage, DamageCause.Projectile); player.LastAttackTarget = entityCollided; } entityCollided.HealthManager.TakeHit(this, (int)damage, DamageCause.Projectile); entityCollided.HealthManager.LastDamageSource = Shooter; DespawnEntity(); return; } } else { var velocity2 = Velocity; velocity2 *= (float)(1.0d - Drag); velocity2 -= new Vector3(0, (float)Gravity, 0); double distance = velocity2.Length(); velocity2 = Vector3.Normalize(velocity2) / 2; for (int i = 0; i < Math.Ceiling(distance) * 2; i++) { Vector3 nextPos = KnownPosition.ToVector3(); nextPos.X += velocity2.X * i; nextPos.Y += velocity2.Y * i; nextPos.Z += velocity2.Z * i; Block block = Level.GetBlock(nextPos); collided = block.IsSolid && block.GetBoundingBox().Contains(nextPos); if (collided && OnBlockColission(block)) { SetIntersectLocation(block.GetBoundingBox(), KnownPosition.ToVector3()); break; } } } if (collided) { Velocity = Vector3.Zero; } else { KnownPosition.X += (float)Velocity.X; KnownPosition.Y += (float)Velocity.Y; KnownPosition.Z += (float)Velocity.Z; Velocity *= (float)(1.0 - Drag); Velocity -= new Vector3(0, (float)Gravity, 0); KnownPosition.Yaw = (float)Velocity.GetYaw(); KnownPosition.Pitch = (float)Velocity.GetPitch(); } // For debugging of flight-path if (BroadcastMovement) { //LastUpdatedTime = DateTime.UtcNow; BroadcastMoveAndMotion(); } }
private bool CheckBlockCollide(PlayerLocation location) { var bbox = GetBoundingBox(); var pos = location.ToVector3(); var coords = new BlockCoordinates( (int)Math.Floor(KnownPosition.X), (int)Math.Floor((bbox.Max.Y + bbox.Min.Y) / 2.0), (int)Math.Floor(KnownPosition.Z)); Dictionary <double, Block> blocks = new Dictionary <double, Block>(); for (int x = -1; x < 2; x++) { for (int z = -1; z < 2; z++) { for (int y = -1; y < 2; y++) { Block block = Level.GetBlock(coords.X + x, coords.Y + y, coords.Z + z); if (block is Air) { continue; } BoundingBox blockbox = block.GetBoundingBox() + 0.3f; if (blockbox.Intersects(GetBoundingBox())) { //if (!blockbox.Contains(KnownPosition.ToVector3())) continue; if (block is FlowingLava || block is StationaryLava) { HealthManager.Ignite(1200); continue; } if (!block.IsSolid) { continue; } blockbox = block.GetBoundingBox(); var midPoint = blockbox.Min + new Vector3(0.5f); blocks.Add(Vector3.Distance((pos - Velocity), midPoint), block); } } } } if (blocks.Count == 0) { return(false); } var firstBlock = blocks.OrderBy(pair => pair.Key).First().Value; BoundingBox boundingBox = firstBlock.GetBoundingBox(); if (!SetIntersectLocation(boundingBox, KnownPosition.ToVector3())) { // No real hit return(false); } // Use to debug hits, makes visual impressions (can be used for paintball too) var substBlock = new Stone { Coordinates = firstBlock.Coordinates }; Level.SetBlock(substBlock); // End debug block Velocity = Vector3.Zero; return(true); }
public override void Update(IUpdateArgs args) { base.Update(args); var dt = (float)args.GameTime.ElapsedGameTime.TotalSeconds; if (IsSneaking) { _body.Rotation = new Vector3(-35f, _body.Rotation.Y, _body.Rotation.Z); _body.Position = Vector3.Forward * 7.5f; //_head.Position = new Vector3(_body.Position.X, 0.25f, 0f); _leftArmModel.Rotation = new Vector3(72f, 0f, 0f); _rightArmModel.Rotation = new Vector3(72f, 0f, 0f); } else { _body.Position = Vector3.Zero; _body.Rotation = new Vector3(0f); var moveSpeed = MovementSpeed; var tcos0 = (float)(Math.Cos(DistanceMoved * 38.17) * moveSpeed) * 57.3f; var tcos1 = -tcos0; var pos = KnownPosition.ToVector3(); float deltaX = pos.X - _prevUpdatePosition.X; float deltaZ = pos.Z - _prevUpdatePosition.Z; float distSQ = deltaX * deltaX + deltaZ * deltaZ; //_armRotation = _armRotation; // Test arm rotations if (_leftArmModel != null && _rightArmModel != null) { //var lArmRot = new Vector3((0.5f + MathF.Sin(_armRotation)) * 7.5f, 0f, // 0.1f + (MathF.Cos(_armRotation) * 1.5f)); Vector3 rArmRot = Vector3.Zero; var lArmRot = new Vector3(tcos0, 0, 0); if (distSQ > 0f) { _armRotation += (float)((new Vector3(Velocity.X, 0, Velocity.Z).Length()) + distSQ) * dt; rArmRot = new Vector3((0.5f + MathF.Cos(_armRotation)) * 24.5f, 0, 0); } else { _armRotation += dt; rArmRot = new Vector3((0.5f + MathF.Cos(_armRotation)) * -7.5f, 0f, 0.1f + (MathF.Sin(_armRotation) * -1.5f)); } _leftArmModel.Rotation = rArmRot; _rightArmModel.Rotation = -rArmRot; _rightSleeveModel.Rotation = -rArmRot; _leftSleeveModel.Rotation = rArmRot; } if (_leftLegModel != null && _rightLegModel != null) { Vector3 lLegRot = Vector3.Zero; Vector3 rLegRot = Vector3.Zero; if (distSQ > 0f) { _legRotation += (float)((new Vector3(Velocity.X, 0, Velocity.Z).Length()) + distSQ) * dt; lLegRot = new Vector3(MathF.Sin(_legRotation) * 34.5f, 0f, 0f); rLegRot = new Vector3(-MathF.Sin(_legRotation) * 34.5f, 0f, 0f); _prevUpdatePosition = pos; } else { _legRotation = 0f; } _leftLegModel.Rotation = lLegRot; _rightLegModel.Rotation = rLegRot; _leftPantsModel.Rotation = lLegRot; _rightPantsModel.Rotation = rLegRot; } } }
private void AdjustForCollision() { var length = Length / 2; var direction = Vector3.Normalize(Velocity * 1.00000101f); var position = KnownPosition.ToVector3(); int count = (int)(Math.Ceiling(Velocity.Length() / length) + 2); for (int i = 0; i < count; i++) { var distVec = direction * (float)length * i; BlockCoordinates blockPos = position + distVec; Block block = Level.GetBlock(blockPos); if (block.IsSolid) { var yaw = (Math.Atan2(direction.X, direction.Z) * 180.0D / Math.PI) + 180; //Log.Warn($"Will hit block {block} at angle of {yaw}"); Ray ray = new Ray(position, direction); if (ray.Intersects(block.GetBoundingBox()).HasValue) { int face = IntersectSides(block.GetBoundingBox(), ray); //Log.Warn($"Hit block {block} at angle of {yaw} on face {face}"); if (face == -1) { continue; } switch (face) { case 0: Velocity *= new Vector3(1, 1, 0); break; case 1: Velocity *= new Vector3(0, 1, 1); break; case 2: Velocity *= new Vector3(1, 1, 0); break; case 3: Velocity *= new Vector3(0, 1, 1); break; case 4: // Under Velocity *= new Vector3(1, 0, 1); break; //case 5: // float ff = 0.6f * 0.98f; // Velocity *= new Vector3(ff, 0.0f, ff); // break; } return; } else { //Log.Warn($"Hit block {block} at angle of {yaw} had no intersection (strange)"); Velocity *= new Vector3(0, 0, 0); } } } }
public override void OnTick() { base.OnTick(); if (Ttl <= 0 || KnownPosition.Y <= 0 || Collided) { DespawnEntity(); } Ttl--; Entity entityCollided = CheckEntityCollide(KnownPosition.ToVector3(), Velocity); bool collided = false; if (entityCollided != null) { entityCollided.HealthManager.TakeHit(Shooter, 2, DamageCause.Projectile); collided = true; } else { //collided = CheckBlockCollide(KnownPosition); if (!collided) { var velocity2 = Velocity; velocity2 *= (1.0d - Drag); velocity2 -= new Vector3(0, Gravity, 0); double distance = velocity2.Distance; velocity2 = velocity2.Normalize() / 2; for (int i = 0; i < Math.Ceiling(distance) * 2; i++) { PlayerLocation nextPos = (PlayerLocation)KnownPosition.Clone(); nextPos.X += (float)velocity2.X * i; nextPos.Y += (float)velocity2.Y * i; nextPos.Z += (float)velocity2.Z * i; Vector3 coord = new Vector3(nextPos.ToVector3()); Block block = Level.GetBlock(coord); collided = block.Id != 0 && (block.GetBoundingBox()).Contains(nextPos.ToVector3()); if (collided) { var substBlock = new Block(57) { Coordinates = block.Coordinates }; Level.SetBlock(substBlock); KnownPosition = nextPos; SetIntersectLocation(block.GetBoundingBox(), KnownPosition); break; } } } } if (collided) { Collided = collided; Velocity = Vector3.Zero; } else { KnownPosition.X += (float)Velocity.X; KnownPosition.Y += (float)Velocity.Y; KnownPosition.Z += (float)Velocity.Z; Velocity *= (1.0 - Drag); Velocity -= new Vector3(0, Gravity, 0); var k = Math.Sqrt((Velocity.X * Velocity.X) + (Velocity.Z * Velocity.Z)); KnownPosition.Yaw = (float)(Math.Atan2(Velocity.X, Velocity.Z) * 180f / Math.PI); KnownPosition.Pitch = (float)(Math.Atan2(Velocity.Y, k) * 180f / Math.PI); } BroadcastMoveAndMotion(); }
public override void OnTick() { base.OnTick(); if (KnownPosition.Y <= 0 || (Velocity.Distance <= 0 && DespawnOnImpact) || (Velocity.Distance <= 0 && !DespawnOnImpact && Ttl <= 0)) { DespawnEntity(); return; } Ttl--; if (KnownPosition.Y <= 0 || Velocity.Distance <= 0) { return; } Entity entityCollided = CheckEntityCollide(KnownPosition.ToVector3(), Velocity); bool collided = false; if (entityCollided != null) { entityCollided.HealthManager.TakeHit(this, 2, DamageCause.Projectile); collided = true; } else { //collided = CheckBlockCollide(KnownPosition); if (!collided) { var velocity2 = Velocity; velocity2 *= (1.0d - Drag); velocity2 -= new Vector3(0, Gravity, 0); double distance = velocity2.Distance; velocity2 = velocity2.Normalize() / 2; for (int i = 0; i < Math.Ceiling(distance) * 2; i++) { PlayerLocation nextPos = (PlayerLocation)KnownPosition.Clone(); nextPos.X += (float)velocity2.X * i; nextPos.Y += (float)velocity2.Y * i; nextPos.Z += (float)velocity2.Z * i; BlockCoordinates coord = new BlockCoordinates(nextPos); Block block = Level.GetBlock(coord); collided = block.Id != 0 && (block.GetBoundingBox()).Contains(nextPos.ToVector3()); if (collided) { var substBlock = new Block(57) { Coordinates = block.Coordinates }; //Level.SetBlock(substBlock); //KnownPosition = nextPos; SetIntersectLocation(block.GetBoundingBox(), KnownPosition); break; } } } } if (collided) { Velocity = Vector3.Zero; } else { KnownPosition.X += (float)Velocity.X; KnownPosition.Y += (float)Velocity.Y; KnownPosition.Z += (float)Velocity.Z; Velocity *= (1.0 - Drag); Velocity -= new Vector3(0, Gravity, 0); //var k = Math.Sqrt((Velocity.X*Velocity.X) + (Velocity.Z*Velocity.Z)); //KnownPosition.Yaw = (float) Vector3.RadiansToDegrees(Math.Atan2(Velocity.X, Velocity.Z)); //KnownPosition.Pitch = (float) Vector3.RadiansToDegrees(Math.Atan2(Velocity.Y, k)); KnownPosition.Yaw = (float)Velocity.GetYaw(); KnownPosition.Pitch = (float)Velocity.GetPitch(); } // For debugging of flight-path if (BroadcastMovement) { BroadcastMoveAndMotion(); } }
private void CalculateLegMovement(IUpdateArgs args) { var pos = KnownPosition.ToVector3(); float distSQ = Vector3.DistanceSquared(_prevUpdatePosition, pos); var distance = DistanceMoved; distSQ = distance; if (!IsMoving) { //DistanceMoved = 0f; } var dt = (float)args.GameTime.ElapsedGameTime.TotalSeconds; if (!ServerEntity) { var distanceMoved = DistanceMoved; DistanceMoved = 0; _mvSpeed = (float)(distanceMoved * (TimeSpan.FromSeconds(1) / args.GameTime.ElapsedGameTime)); } if (IsSneaking && _body != null) { var posOffset = new Vector3(0f, -1.5f, -4.5f); _body.Rotation = new Vector3(-25f, _body.Rotation.Y, _body.Rotation.Z); _body.Position = posOffset; //_head.Position = new Vector3(_body.Position.X, 0.25f, 0f); if (_rightArmModel != null && _leftArmModel != null) { _leftArmModel.Rotation = new Vector3(-20f, 0f, 0f); _leftArmModel.Position = posOffset; if (!_rightArmModel.IsAnimating) { _rightArmModel.Rotation = new Vector3(-20f, 0f, 0f); } _rightArmModel.Position = posOffset; if (_rightSleeveModel != null && _leftSleeveModel != null) { _rightSleeveModel.Rotation = _rightArmModel.Rotation; _rightSleeveModel.Position = posOffset; _leftSleeveModel.Rotation = _leftArmModel.Rotation; _leftSleeveModel.Position = posOffset; } } if (_head != null) { _head.Position = posOffset; } } else if (_body != null && !IsSneaking) { _body.Position = Vector3.Zero; _body.Rotation = new Vector3(0f); if (_rightArmModel != null && _leftArmModel != null) { _rightArmModel.Position = _leftArmModel.Position = Vector3.Zero; if (_rightSleeveModel != null && _leftSleeveModel != null) { _rightSleeveModel.Rotation = _rightArmModel.Rotation; _rightSleeveModel.Position = Vector3.Zero; _leftSleeveModel.Rotation = _leftArmModel.Rotation; _leftSleeveModel.Position = Vector3.Zero; } } if (_head != null) { _head.Position = Vector3.Zero; } } var moveSpeed = MovementSpeed * 20f; var tcos0 = (float)(Math.Cos(distance * (38.17 * 20f)) * moveSpeed) * (57.3f * 20f); var tcos1 = -tcos0; //_armRotation = _armRotation; // Test arm rotations if (!IsSneaking && _leftArmModel != null && _rightArmModel != null) { //var lArmRot = new Vector3((0.5f + MathF.Sin(_armRotation)) * 7.5f, 0f, // 0.1f + (MathF.Cos(_armRotation) * 1.5f)); Vector3 rArmRot = Vector3.Zero; var lArmRot = new Vector3(tcos0, 0, 0); if (distSQ > 0f) { if (!IsMoving) { _armRotation = 0f; IsMoving = true; } _armRotation += (float)(_mvSpeed) * dt; //rArmRot = new Vector3(tcos0, 0, 0); rArmRot = new Vector3((0.5f + MathF.Cos(_armRotation)) * 24.5f, 0, 0); } else { IsMoving = false; _armRotation += dt; rArmRot = new Vector3( (0.5f + MathF.Cos(_armRotation)) * -7.5f, 0f, 0.1f + (MathF.Sin(_armRotation) * -1.5f)); } _leftArmModel.Rotation = rArmRot; if (!_rightArmModel.IsAnimating) { _rightArmModel.Rotation = -rArmRot; } if (_rightSleeveModel != null && _leftSleeveModel != null) { _rightSleeveModel.Rotation = -rArmRot; _leftSleeveModel.Rotation = rArmRot; } } if (_leftLegModel != null && _rightLegModel != null) { Vector3 lLegRot = Vector3.Zero; Vector3 rLegRot = Vector3.Zero; if (distSQ > 0f) { _legRotation += (float)(_mvSpeed) * dt; ; lLegRot = new Vector3(MathF.Sin(_legRotation) * 34.5f, 0f, 0f); rLegRot = new Vector3(-MathF.Sin(_legRotation) * 34.5f, 0f, 0f); //lLegRot = new Vector3(tcos0, 0f, 0f); //rLegRot = new Vector3(tcos1, 0f, 0f); } else { _legRotation = 0f; } _leftLegModel.Rotation = lLegRot; _rightLegModel.Rotation = rLegRot; if (_leftPantsModel != null && _rightPantsModel != null) { _leftPantsModel.Rotation = lLegRot; _rightPantsModel.Rotation = rLegRot; } } var itemRender = ItemRenderer; var rightArm = _rightArmModel; if (itemRender != null && rightArm != null) { } _prevUpdatePosition = pos; }