We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System Specs
Manjaro GNOME 21 AMD R7 200 series Intel i3 3rd Gen 3.0 GHZ 8GB RAM SSD 120GB
Tests
I've converted the Movement tests to GDNative using C++ and here's my results:
Movement
Soon I'll convert more and make a PR, so people can test in Linux and Windows
Linux
Windows
I'll disponibilizate the Source in PR, for now here's how it was made:
Movement.h
#ifndef MOV_H #define MOV_H #include <Godot.hpp> #include <KinematicBody.hpp> #include <KinematicCollision.hpp> #include <Vector3.hpp> namespace godot { class Movement : public KinematicBody { GODOT_CLASS(Movement, KinematicBody) private: float time_passed; float move_speed = 10.0; float gravity = 10.0; int move_group = 0; int num_of_move_groups = 3; Vector3 startPos, endPos, velocity = Vector3().ZERO; bool first_run = true; enum MOVE_MODES { MOVE_AND_COLLIDE, MOVE_AND_SLIDE, MOVE_AND_SLIDE_SNAP, TIME_SPLICED }; int move_mode = 0; void set_move_mode(int move_mode); int get_move_mode(); public: static void _register_methods(); Movement(); ~Movement(); void _init(); // our initializer called by Godot void _physics_process(float delta); void move_time_spliced(Vector3 vel, Vector3 upVec); }; } #endif
Movement.cpp
#include "Movement.h" using namespace godot; void Movement::_register_methods() { register_method("_physics_process", &Movement::_physics_process); register_method("move_time_spliced", &Movement::move_time_spliced); register_property<Movement,int>("move_mode",&Movement::set_move_mode,&Movement::get_move_mode,0); } Movement::Movement() { } Movement::~Movement() { // add your cleanup here } void Movement::_init() { // initialize any variables here move_group = rand() % num_of_move_groups; } void Movement::_physics_process(float delta) { Vector3 move_vec = Vector3().RIGHT; Vector3 grav_vec = Vector3().DOWN * gravity * delta; if ( is_on_floor() ){ grav_vec = Vector3().ZERO; velocity.y = .01; } Vector3 dragVec = Vector3(velocity.x * .9, .0, velocity.z * .9); velocity += move_vec * move_speed - dragVec + grav_vec; switch(move_mode) { case MOVE_MODES::MOVE_AND_COLLIDE: move_and_collide(velocity * delta); break; case MOVE_MODES::MOVE_AND_SLIDE: move_and_slide(velocity, Vector3().UP); break; case MOVE_MODES::MOVE_AND_SLIDE_SNAP: move_and_slide_with_snap(velocity,Vector3().DOWN,Vector3().UP); break; case MOVE_MODES::TIME_SPLICED: move_time_spliced(velocity,Vector3().UP); break; } } void Movement::move_time_spliced(Vector3 vel, Vector3 upVec) { move_group += 1; move_group %= num_of_move_groups; if ( move_group == 0 ) { startPos = get_global_transform().origin; move_and_slide(vel * num_of_move_groups, upVec); endPos = get_global_transform().origin; first_run = false; } if ( !first_run ) { float t = (move_group+1.0)/num_of_move_groups; get_global_transform().origin = startPos.linear_interpolate(endPos, t); } } void Movement::set_move_mode(int move_mode) { this->move_mode = move_mode; } int Movement::get_move_mode() { return move_mode; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
System Specs
Manjaro GNOME 21
AMD R7 200 series
Intel i3 3rd Gen 3.0 GHZ
8GB RAM
SSD 120GB
Tests
I've converted the
Movement
tests to GDNative using C++ and here's my results:Results With GDScript
Movement
Results With GDNATIVE
Movement
Soon I'll convert more and make a PR, so people can test in
Linux
andWindows
I'll disponibilizate the Source in PR, for now here's how it was made:
Movement.h
Movement.cpp
The text was updated successfully, but these errors were encountered: