Run speed or Jump doesn't increase, why?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By siten0308

Hello,

new to Godot, coming from unity, i have been looking at tutorials to help me better understand the scripting, and the Engine structure especially the layer of nodes etc.

i am creating a simple 2d Platform, this platform has a node, with a child kinematic2d and the child has a sprite. I made a script and attached it to the Kinematic2d, which i am debating what is the difference if i attach it to the sprite or the kinematic2d? anyways, the real problem, is, i am looking at the documentation of godot:

already i found 2 problems, the 2/2 problem is really what i am asking, which is this code below:

using Godot;

using System;

public class KBExample : KinematicBody2D
{
[Export] public int RunSpeed = 100;
[Export] public int JumpSpeed = -400;
[Export] public int Gravity = 1200;

Vector2 velocity = new Vector2();
bool jumping = false;

public void getInput()
{
    velocity.x = 0;
    bool right = Input.IsActionPressed("ui_right");
    bool left = Input.IsActionPressed("ui_left");
    bool jump = Input.IsActionPressed("ui_select");

    if (jump && IsOnFloor())
    {
        jumping = true;
        velocity.y = JumpSpeed;
    }
    if (right)
    {
        velocity.x += RunSpeed;
    }
    if (left)
    {
        velocity.x -= RunSpeed;
    }
}

public override void _PhysicsProcess(float delta)
{
    getInput();
    velocity.y += Gravity * delta;
    if (jumping && IsOnFloor())
    {
        jumping = false;
    }
    velocity = MoveAndSlide(velocity, new Vector2(0, -1));
}

}

when i go to increase the RunSpeed variable from 100 to 700, it still goes the same speed, when i try and change the graivty or even the Jumpspeed, nothing increases or no difference in the movement of the KinematicBody2d, why is that? something i have to set or do something else after making the change? i just hit the “Play Project” button but nothing ever changes… in terms of jumping higher or running faster :frowning:

:bust_in_silhouette: Reply From: siten0308

AHHHH i figured it out, ok, so the problem is, i am not sure if its due to doing C# and using the scripts instead of GDScript, but once you make a change on the cs C# script, you must go to Mono which is located where the bottom is, where it says “Output”, then “Debugger”, then “audio” etc., and there you should see “Mono”, click on it, then go to the button that says “Build Project”, once you did that, after any changes you made will finally reflect it.

I really hope someone add this so the documentation of Godot for C# portion of it.

Also 1 last thing, there seems to be an issue on the GODOT documentation page:

specifically the code that says :

using Godot;
using System;

public class KBExample : KinematicBody2D
{
public int Speed = 250;
private Vector2 _velocity = new Vector2();

public void getInput()
{
    // Detect up/down/left/right keystate and only move when pressed
    _velocity = new Vector2();
    if (Input.IsActionPressed("ui_right"))
    {
        _velocity.x += 1;
    }
    if (Input.IsActionPressed("ui_left"))
    {
        _velocity.x -= 1;
    }
    if (Input.IsActionPressed("ui_down"))
    {
        _velocity.y += 1;
    }
    if (Input.IsActionPressed("ui_up"))
    {
        _velocity.y -= 1;
    }
}

public override void _PhysicsProcess(float delta)
{
    getInput();
    MoveAndCollide(velocity * delta);
}

}

the problem is line:

MoveAndCollide(velocity * delta);

it says velocity… shouldnt that be _velocity? when i copy and run it, i get error message:

“velocity doesn’t exist”

SORRY THIS IS NOT WORKING AGAIN, i THOUGHT THIS WAS THE ANSWER, but AFTER TRYING 5 TIMES TO CHANGE, Compile, recompile through mono and my steps. IT DOESNT WORK!!!

COME ON GODOT, WORK!!!

maybe i should stick with unity until Godot gets this fixed…

siten0308 | 2018-12-30 06:59

UNBELIEVABLE… so converting it from C# to GDScript… everything works… so C# is still buggy and not working correctly… turned off by this… going to try and see about C++, hopefully that part works… which is the only way it will get me to stay with Godot… if not, i will go with Cocos2d and maybe… maybe come back and see how godot is doing in a couple years…

siten0308 | 2018-12-30 07:06

Hi,
So it looks like you found a bug? Would you kindly open an issue in github so developers see it?

p7f | 2018-12-31 14:36

Sorry for late reply, how or where can i go on github specifically and report this bug?

siten0308 | 2019-01-02 16:18

sorry i found the github godot part:

https://github.com/search?l=C%23&q=godot&type=Issues

however it doesnt or maybe i cant find a way to open a issue under C#… any idea?

siten0308 | 2019-01-02 16:21