/// <summary> /// Set the velocity of this <see cref="PhysicsObject"/>. /// </summary> /// <param name="velocity"></param> public void SetVelocity(Vector3 velocity) { var action = new pe_action_set_velocity(); action.v = velocity; NativeHandle.Action(action); }
/// <summary> /// Move this instance. May be overriden in inheriting classes. /// </summary> public virtual Vec3 Move() { // HAndle null? if (!Exists) { return(Vec3.Zero); } // Empty jetPosition means x, y and z are all 0. if (this is ProjectileBase) { if (!_isVelocitySet) { if (PhysicalEntity != null) { var peASV = new pe_action_set_velocity(); peASV.v = Speed; PhysicalEntity.Action(peASV); } _isVelocitySet = true; } return(Position); } Vec3 newPosition = Position + FrameTime.Normalize(Speed); Position = newPosition; return(newPosition); }
void CreateBall() { var ball = GameObject.Instantiate <Ball>(); balls.Add(ball); ball.OnDestroy += () => balls.Remove(ball); var rnd = new Random(); ball.Position = new Vec3(0, 0, rnd.Next(8, 12)); ball.Scale = new Vec3(Vec3.One * (float)(rnd.Next(5, 7) / 10f)); ball.Rotation = new Quat(new Ang3(rnd.Next(1, 10), rnd.Next(1, 10), rnd.Next(1, 10))); var physParams = new SEntityPhysicalizeParams() { mass = 10, density = -1, type = (int)EPhysicalizationType.ePT_Rigid, }; ball.Entity.BaseEntity.Physicalize(physParams); var physImpulse = new pe_action_set_velocity() { v = new Vec3(rnd.Next(-5, 5), rnd.Next(-5, 5), rnd.Next(1, 5)), }; ball.Physics.Action(physImpulse); }
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(); } }