/// <summary> /// Throw Projectile method /// </summary> private void ThrowProjectile() { // Create new projectil if (!string.IsNullOrEmpty(this.ProjectilePrefab)) { this.projectileEntity = this.EntityManager.Instantiate(this.ProjectilePrefab); this.projectileEntity.Name = string.Format("Projectile" + proyectileInstances++); this.projectileEntity.IsSerializable = false; Transform2D projectileTransform = this.projectileEntity.FindComponent <Transform2D>(); projectileTransform.LocalPosition = arcTransform.LocalPosition; projectileTransform.LocalRotation += arcTransform.LocalRotation; projectileTransform.LocalScale = arcTransform.LocalScale; this.EntityManager.Add(this.projectileEntity); } // Throw if (this.projectileEntity != null) { Transform2D projectileTransform = this.projectileEntity.FindComponent <Transform2D>(); RigidBody2D projectileBody = this.projectileEntity.FindComponent <RigidBody2D>(); Collider2D collider = this.projectileEntity.FindComponent <Collider2D>(false); collider.BeginCollision += this.Collider_BeginCollision; Vector2 arrowPointing = Vector2.Transform(Vector2.UnitX * 100, projectileTransform.WorldTransform); Vector2 flightDirection = arrowPointing - projectileTransform.Position; flightDirection.Normalize(); Vector2 arrowTailPosition = Vector2.Transform(Vector2.UnitX * -35, projectileTransform.WorldTransform); projectileBody.ApplyForce(flightDirection * this.Force, arrowTailPosition); } }