public void Initialize(ProjectileData projectileData) { Entity.LoadGeometry(0, projectileData.Shape); if (!string.IsNullOrWhiteSpace(projectileData.MaterialUrl)) { Entity.LoadMaterial(projectileData.MaterialUrl); } var physics = Entity.Physics; var physicsParameters = new RigidPhysicalizeParams(); physicsParameters.Mass = projectileData.Mass; physics.Physicalize(physicsParameters); Entity.SetViewDistanceRatio(1.0f); Vector3 _shotdirection = Entity.WorldRotation.Forward; physics.AddImpulse(_shotdirection * projectileData.Speed); }
public void Initialize(BulletData bulletData) { // Set the model Entity.LoadGeometry(0, bulletData.GeometryUrl); // Load the custom bullet material. if (!string.IsNullOrWhiteSpace(bulletData.MaterialUrl)) { Entity.LoadMaterial(bulletData.MaterialUrl); } // Now create the physical representation of the entity var physics = Entity.Physics; var physicParams = new RigidPhysicalizeParams(); physicParams.Mass = bulletData.Mass; physics.Physicalize(physicParams); // Make sure that bullets are always rendered regardless of distance Entity.SetViewDistanceRatio(1.0f); physics.AddImpulse(Entity.WorldRotation.Forward * bulletData.Speed); }