Home Game Development c++ – How to get my node to solely execute _process_physics when the sport is NOT paused and by no means within the editor?

c++ – How to get my node to solely execute _process_physics when the sport is NOT paused and by no means within the editor?

0
c++ – How to get my node to solely execute _process_physics when the sport is NOT paused and by no means within the editor?

[ad_1]

I’ve carried out a easy “rocket” in 2D, it accepts UP and DOWN for acceleration and left/proper for rotation. The implementation seems like this:

void Player::_physics_process(double delta)
{
    UpdateMotionFromInput(delta);
    set_velocity(movement);
    set_rotation(rotation);
    move_and_slide();
}

void Player::UpdateMotionFromInput(double delta)
{
    const Input* i = Input::get_singleton();

    double delta_v = 0;
    if (i->is_action_pressed("ui_up"))
        delta_v += acceleration * delta;
    if (i->is_action_pressed("ui_down"))
        delta_v -= acceleration * delta;
    if (i->is_action_pressed("ui_left"))
        angular_velocity -= angular_acceleration * delta;
    if (i->is_action_pressed("ui_right"))
        angular_velocity += angular_acceleration * delta;

    constexpr float pi_factor = 360.0f / 3.14f;

    rotation += angular_velocity * delta;
    angular_velocity -= SIGN(angular_velocity) * angular_dampening * delta;

    Vector2 newVec(0, -delta_v);
    movement = movement + newVec.rotated((float)(rotation));
}

Now the issue is, this nonetheless works even within the editor – if I press the arrows the rocket will begin flying round my editor. There’s a Process possibility within the node part, however that doesn’t actually work for me, for the given choices, I get these outcomes:

  1. When paused, Disabled – does not do something ever.
  2. Inherit, Pausable, Always – at all times executes _process_physics

I wish to course of physics when the sport is run, not when I’m in editor. How can I try this?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here