public void SetImpulse(Vec3 target, float speed, float timeToLive = 10f) { Physics.Physicalize(5, EPhysicalizationType.ePT_Rigid); Physics.Action <pe_action_set_velocity>((impulse) => { impulse.v = (target - Position).Normalized * speed; }); timeToLiveTimer = new Timer(timeToLive, () => Destroy()); }
void IMouseDown.OnMouseDown(MouseButton button) { Debug.Log("OnMouseDown!"); if (button == MouseButton.Left) { var physImpulse = new pe_action_set_velocity() { v = new Vec3(Vec3.Up * 15f), }; Physics.Action(physImpulse); } else { Destroy(); } }
public void Launch() { GetParticleEffect("particle_trail", (pfx) => NativeEntity.LoadParticleEmitter(1, pfx)); // Launch the firework upwards. Physics.Action <pe_action_impulse>((action) => { action.impulse = Rotation.Forward * 100f; }); var rnd = new Random().Next((int)MinTime * 100, (int)MaxTime * 100) / 100f; // Start a timer that will trigger the explosion. new Timer(rnd, () => { // Spawn the explosion effect then remove this entity. GetParticleEffect("particle_explosion", (pfx) => pfx.Spawn(Position)); Remove(); }); }