Git Product home page Git Product logo

godot-rapier-2d's People

Contributors

antonbergaker avatar fabriceci avatar ughuuu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

godot-rapier-2d's Issues

Investigate Cross Platform Determinsim

Right now the plugin isn't cross platform deterministic. The issues could be from:

  • The internal state of the plugin
  • The wrapper of rapier
  • Something else

From my investigation the plugin uses .length(), as it uses Vector2 of godot-cpp, which in turn uses sqrt, which isn't cross platform deterministic.

Need to investigate other possible things as well. After asking on chat.godotengine.com about it, got some helpful tips as well:

AThousandShips:

Then it isn't related to the extension code itself, and the only possible cause is the cross-platform differences in sqrt etc.
As the built-in types like those are entirely self-contained on extensions, for performance reasons
But I'd suggest just testing the output of various simple operations across platforms just to see, generate a bunch of vectors for example and run the operations on them on both systems, just create a data file to store them in and load them on both machines
If they yield the same results then it's going to be the way you've translated this library to the language in question, it's easy to make mistakes when translating between languages
And of course make sure you're actually setting up a test that ensures determinism, because floating point mathematics isn't deterministic when out of order due to rounding, so it's important that your testing conditions are actually such that they test for determinism
And, and this is really important, make sure the data for the tests are dynamic, no compile time tests, it has to be loaded, because that's a classic trap
Especially with floating point math compile time and runtime is a mess

Static body constant speed (conveyer belt) doesn't work for rigidbodies

Describe the bug

Static body constant speed (conveyer belt) doesn't work

To Reproduce

Steps to reproduce the behavior:

Create a one way platform
Create a rigidbody with a shape

Expected behavior

The body should have it's speed changed by the static body

Environment (please complete the following information):

OS: macOS
Version v0.3
Godot Version v4.2
Type simd single

CharacterBody has issues with tile edges

Untitled.mov

I have tried this with the box shaped and pill shaped character colliders and with the same result. It gets stuck when trying to jump and holding movement towards the wall.

CharacterBody collider seems to penetrate into the wall.

Deactivated collider and/or collider shape doesn't deactivate.

Never mind. I think I'm just a git and programed myself into a corner or something... I'm going to have to just start the game over I guess because I can't seem to get it right. So, I think it's fine I just didn't make a unique collider... but that's not what is wrong in my main game so I dunno... probably just me being shit even though I've done this for a couple of decades.

Tunneling issue in RigidBody2d

Describe the bug
On applying impulse or force on RigidBody2d by a CharacterBody2d the body moves out of the scene through walls.
Without rapier extension it works fine.

To Reproduce
Steps to reproduce the behavior:

peek_6.mp4

Expected behavior
Even after setting infinite impulse to false and making the collision walls (StaticBody2d with CollisionShape2d) the RigidBody2d should not phase through the wall / scene.

Screenshots
(video attached)

Reference project:
https://github.com/souvikinator/test-gdt

Environment (please complete the following information):

  • OS: Windows 11
  • Version v0.5.1
  • Godot Version v4.2

PinJoint2D Disable Collision does not work

Disable Collision is working if using the Godot physics engine.
When using rapier2d, use PinJoint2D to connect two Rigidbody2D and they will collide with each other even when Disable Collision is checked.

  • OS: Windows
  • Godot Version v4.2-beta4
  • rapier2d version v0.5.1

Thank you for your excellent work!

Project won't open after installing any of the plugin versions from asset store

Describe the bug
Project won't open after installing any of the plugin versions from asset store and reloading the project, no crash log files that i could find from godot engine.

To Reproduce

1 open godot 4.2.1
2 create a project
3 install godot rapier from asset store
4 restart engine or reload project
5 crashes

Expected behavior

shouldnt crash

Environment (please complete the following information):

Godot v4.2.1.stable - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4060 (NVIDIA; 31.0.15.5123) - Intel(R) Core(TM) i3-10100F CPU @ 3.60GHz (8 Threads)

Example project(zip)

New project

get_overlapping_areas() returns reference to self

Describe the bug
Calling get_overlapping_areas() on Area2D can return array with reference to self instead of other Area2D

To Reproduce
Steps to reproduce the behavior:

  1. Create 2D scene containing 2 Area2Ds (Area1, Area2) with CollisionShap2D circles which are overlapping
  2. In script on scene root inside _physics_process call get_overlapping_areas() on Area1. It returns [Area2]
  3. Calling get_overlapping_areas() on Area2. Also returns [Area2]

Expected behavior
Calling Area1.get_overlapping_areas() should return [Area2]] (which it does)
Calling Area2.get_overlapping_areas() should return [Area1]] (which it does not)

Screenshots
Screenshot from 2024-03-05 21-40-59

Screenshot from 2024-03-05 21-40-36

Environment (please complete the following information):

  • OS: Linux, Ubuntu 22.04
  • Godot Version v4.2.1
  • Source: Plugin from Godot Asset Store (Godot Rapier 2D)
  • Plugin Version: 0.5.1
  • Rapier Version: 0.17.2 2

Rigidbody 2D with no damp still slows down

I think this one is legit. So in the Godot phys engine, objects with zero linear damp will go in their direction forever. Likewise, zero angular damp should spin forever. In Godot Rapier both linear and angular slow over time with zero damp, tossing the first law of motion out the window like a baby with the bath water... or something.

Anything that moves in this project exhibits the behavior: https://github.com/GeminiSquishGames/Rapier2Dbug

Seems like Replace rather than Combine mode helps, but this isn't how Godot works. Pretty sure zero damp should let the object move forever unless acted upon in order to simulate it right... I think.

Incorrect raycast results against CollisionPolygon2D with `build_mode = BUILD_SOLIDS`

Describe the bug
Raycasts sometimes tunnel through polygon shapes with the "Solids" build mode.

To Reproduce
I've attached a project demonstrating the behavior. Simply move the mouse around to see the difference between raycasting against solids vs segments.

Expected behavior
Raycasts against polygons with build_mode = BUILD_SOLIDS should behave approximately the same as raycasts against polygons with build_mode = BUILD_SEGMENTS.

Screenshots
Blue = Raycast result against segments
Orange = Raycast result against solids
raycast_error

Environment

  • OS: Windows
  • Version v0.5.1
  • Godot Version v4.2.1

RaycastDemo.zip

Problems with velocities, default body rotation, colliders get stuck, events not getting called, etc.

It's hard to describe what I'm experiencing. All I can say is I had a working asteroid-like game going, and now very few things work as they do with the default.

The bullet speeds are much slower and aren't registering hits.

I spawn asteroids in with a random linear_velocity and angular_velocity set so they distribute that as they move around, but now they simply have a constant rotation and are not distributing the angular velocity properly, or at all really. As if they are on a constant torquing motor and angular velocity keeps the same value without dampening. This is the SMID faster version. But it seems like no rotation happens in slower ED version.

My player rigid body would point at the mouse cursor but it goes out of sync now when things kind of collide but get stuck to it. It seems better but still happens in slower ED version.

The shield is just a collider alongside the ship's colliders that deactivates when not in use, but it seems like I can't deactivate the collider like I was before and it's always on. I could perhaps instance it and free it but it also grows and shrinks by manipulating the circle shape's radius, this also no longer works at all, but did with default. Both versions do this.

If that collider is touching anything else it will get the RBody stuck. The ship will no longer gain directional thrust and just gets stuck on the object. the slower ED version is much better about this, doesn't seem to get stuck.

Collectables that once collected properly no longer do so and simply push the ship around if I manually override the shield off in the editor during runtime. So it seems like the layers are not working properly. This happens in faster version SIMD, the slower ED will collect when hitting the always on sheild

As it is I can't really use the addon to replace the default physics system at this time as I have no control over these issues and have no idea what is wrong or what to do.

Edit: Also, move_toward seems to automatically face in the direction in the faster SIMD one, objects that were not meant to rotate now do. Default does not. It also seems to turn toward using the bottom of the rigid body, as though down is forward. The default is right is forward facing. May be why the rotation of the ship doesn't follow the mouse as well. also updated to which versions these problems are in.

Overlapping spawns seem to need a lot more leeway or they create way more velocity on objects. Can just make sure overlaping objects dampen or spawn further away before applying any force. both versions.

Player object in space shooter bullet speeds are much slower and aren't registering hits.

Compared to the actions of default, when set to the Rapier plugin, bullets travel much slower. Regardless of speed they also seem to not trigger the usual methods on collisions as the default does. Setting the speed much higher seems to fix this but doesn't match the default use. For example, look in the repo I sent @Ughuuu an invite to, should be set to Default and has Rapier (slow version) installed.

Edit: this and any other problems with speed can be fixed by:

if ProjectSettings.get_setting("physics/2d/physics_engine") == "Rapier2D":

and setting the values accordingly. Not sure what the magic number is but maybe something around [ speed *= 20 ] This may also affect other rigid bodies, like how fast the asteroids are when they spawn in, but it probably needs to match the speed of DEFAULT.

another edit: I will try to put a test scene in the res:// with easy bug reproductions so you can just test from there and not have to run the whole project to find the issues.

PhysicsDirectSpaceState2D.intersect_shape not working

extends Node2D

var query: PhysicsShapeQueryParameters2D

func _ready():
	# 1 by 1 square at origin
	var shape: RID = PhysicsServer2D.rectangle_shape_create()
	PhysicsServer2D.shape_set_data(shape, Vector2(0.5, 0.5))
	var body: RID = PhysicsServer2D.body_create()
	PhysicsServer2D.body_set_space(body, get_world_2d().get_space())
	PhysicsServer2D.body_add_shape(body, shape)
	PhysicsServer2D.body_set_state(body, PhysicsServer2D.BODY_STATE_TRANSFORM, Transform2D(0, Vector2(0, 0)))
	PhysicsServer2D.body_set_mode(body, PhysicsServer2D.BODY_MODE_STATIC)
	
	# circle query at 10, 10 with radius 100
	var circle := CircleShape2D.new()
	circle.radius = 100
	
	query = PhysicsShapeQueryParameters2D.new()
	query.shape = circle
	query.transform = Transform2D(0, Vector2(10, 10))
	
func _physics_process(delta):
	var direct_space_state := get_world_2d().direct_space_state
	var results := direct_space_state.intersect_shape(query)
	print(results.size())

Only prints 0 on Rapier2D, will print 1 on default

RigidBody2D body_entered signal not emitting on collisions when bounce is enabled on the physics material

Describe the bug
On a RigidBody2D node with a circle collision shape and a physics material with bounce set to 1, the built in body_entered signal is not emitted on collisions with StaticBody2Ds.

To Reproduce
Steps to reproduce the behavior:

  1. Create a RigidBody2D node
  2. Give it a CollisionShape2D (Not sure if shape matters, but mine is a circle)
  3. Give the RigidBody2D a physics material with bounce set to 1
  4. Upon collision with a StaticBody2D node, the built in body_entered signal is never emitted

Expected behavior
The body_entered signal should be emitted (Works properly on both Box2D and GodotPhysics)

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows 11
  • Godot Version: 4.2 beta 4

Rewrite addon to rust

As of now, the addon has parts in c++ and a wrapper in rust.
Because of this, it's hard to make web builds work (because of the first wrapper in rust, it needs some js hacks to work).
GDext(godot-rust) extension somehow figured it out. It might be difficult to do here.
Also, cross platform determinism is way easier to do in rust than in c++.

That being said, I think it would be most beneficial to have all the code written in rust, and not have 2 layers of code(c++ and rust).

"shape_count < 1 is true" when CollisionShape is disabled

Describe the bug
Calling move_and_slide when collision shape is disabled results in the following error

E 0:00:09:0544 ProjectileCollision.gd:61 @ _physics_process(): Condition "shape_count < 1" is true. Returning: false
<C++ Source> src\servers\rapier_body_utils_2d.cpp:46 @ RapierBodyUtils2D::body_motion_recover()
ProjectileCollision.gd:61 @ _physics_process()

Error location:

ERR_FAIL_COND_V(shape_count < 1, false);

To Reproduce
Steps to reproduce the behavior:

  1. Create a node with CollisionShape2D (I have RectangleShape2D)
  2. Disable the CollisionShape on the fly
  3. Call move_and_slide
  4. Console fills with errors

Expected behavior
Console shouldn't fill with error

Environment

  • OS: Windows 11
  • Version 0.5.1
  • Godot Version 4.2 - Steam
  • Got it from asset store

One Way Collision doesn't work for rigidbodies

Describe the bug
One Way Collision doesn't work

To Reproduce
Steps to reproduce the behavior:

  1. Create a one way platform
  2. Create a rigidbody with a shape

Expected behavior
The body should go through the one way platform.

Environment (please complete the following information):

  • OS: macOS
  • Version v0.3
  • Godot Version v4.2
  • Type single

Rapier2D doesn't work the same as Default with Physics Materials Godot 4.2.1 mono

The example project is: https://github.com/GeminiSquishGames/Rapier2Dbug

The box static collision has a physics material set for max bounce and friction, no absorb. The ball is a plain RBody. Switch between the two physics engines to see that Rapier behaves more erratically with the same settings as Godot's default which it should be set too when you open it. This is using Godot 4.2.1 mono,

Edit: Seems like rough-checked friction applies the wrong angular velocity, transfers to the opposite rotational velocity. Then it collects too much linear?

Godot 4.2 WorldBoundaryShape glitches

Describe the bug

There are two bugs:

  1. It ignores the distance parameter
  2. It has inverted normal parameter
  3. Everything behind it is stopped (which isn't so with default godot physics)
  4. When object touches the world boundary it also becomes "freezed"

To Reproduce

  1. Clone https://github.com/dustdfg/godot_rapier_example
  2. Run with default physics
    2.1. Run with adjusting normal to y = +1
    2.2. Run with adjusting distance parameter
  3. Run with rapier physics
    3.1. Run with adjusting normal to y = +1
    3.2. Run with adjusting distance parameter

Expected behavior
As with default physics

Environment (please complete the following information):

  • OS: Debian12
  • Version:0.5.1
  • Godot Version: v4.2.1
  • Type [e.g. simd single is the default one from asset store] From asset store

Invalid shape exception when collision shape is disabled

Describe the bug
Rapier2D seems to crash if there is a collision shape 2D that is disabled in the Node inspector.
imagen

E 0:00:03:0538   _update_shape_transform: Condition "!rapier2d::is_handle_valid(shape.collider_handle)" is true.
  <C++ Source>   src/bodies/rapier_collision_object_2d.cpp:247 @ _update_shape_transform()

To Reproduce
Steps to reproduce the behavior:

  1. Create a RigidBody2D
  2. Add CollisionShape2D to the RigidBody2D
  3. Disable the CollisionShape2D
  4. Run scene

Expected behavior
No error.

Screenshots

Environment (please complete the following information):

  • OS: Mac arm64
  • Version: 0.6.11 SIMD
  • Godot Version Godot 4.3-dev5
  • Type SIMD Godot Library

Example project(zip)

rapier2dcylinder.zip

Please attach a zip with project where issue occurs.

CollisionPolygon2D with `build_mode = BUILD_SEGMENTS` is not closed

Describe the bug
The segment between the first and last point on a CollisionPolygon2D with build_mode = BUILD_SEGMENTS is missing.

To Reproduce
Steps to reproduce the behavior:

  1. Create a StaticBody2D with a CollisionPolygon2D
  2. Set the CollisionPolygon2D build mode to "Segments"
  3. Move a CharacterBody2D into the last segment in the polygon

Screenshots
missing_segment

Environment

  • OS: Windows
  • Version v0.5.1
  • Godot Version v4.2

Use a data holder and send it through layers

In the new versions rust rewrite, I use now a singleton locked with a mutex to access data.
Instead, I should give a reference to the data holder to all layers, and possiblity use a hashmap that can handle access from multiple threads(dashmap)

point gravity not working as intented - using area2d example doesn't function correctly

Objects that get attracted towards a point gravity area don't slow down once they moved across the gravity point.

To Reproduce

  1. Go to https://docs.godotengine.org/en/stable/tutorials/physics/using_area_2d.html and download the example at the bottom of the page
  2. Open project
  3. Install godot-rapier-2d from asset store
  4. change physics 2d to rapier
  5. Start project and play with the point gravity, to see that it doesn't work

Expected behavior:
I would expect it to behave similar to the default godot physics engine. If a Ball is spawned close to the middle of the gravity point area it should move around the center point. But with rapier physics engine it gets thrown out.

I have tried playing with the physics parameters but i can't get it to work.

Environment :

  • OS: Fedora (linux)
  • Version 39
  • Godot Version v4.2.1.stable.mono (I also tried with 4.2.1.stable.fedora)
  • Type: the default one from asset store (v0.5.1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.