Godot: Area not detecting Trimesh Static Bodies

Created on 13 Apr 2019  路  6Comments  路  Source: godotengine/godot

Godot version: 3.1
OS/device including version: Windows 10 Home 1803

Issue description:
I'm trying to create stepping for a kinematic controller. I'm using is_on_wall() to detect if the player is being stopped by a collision and the Area node to detect walls taller than the step height.
The Area node does not detect overlap with generated Trimesh Static Bodies for custom environment models. Both the signals and the get_overlapping_bodies() function do not return anything. It works fine with convex and primitive statics. I've searched and haven't seen any issues addressing this. I can't even really find much information on Trimesh Statics.

Steps to reproduce:

  1. Create a MeshInstance and generate a Trimesh Static Body for it
  2. Create an Area Node with a script to accept signals, or call overlap methods
  3. Move the Area Node into the Trimesh Static Body
  4. Weep at the complete lack of activity

-Or-

  1. Download my minimal
  2. Use Arrow keys or WASD to move the Area into different statics to see results

Things I've tried:

  • Changing the shape of the Area
  • Making the static trimesh body the parent node
  • Using _on_Area_body_shape() signals

Minimal reproduction project:
AreaTrimeshBug.zip

bug physics

Most helpful comment

This issue should be prioritized. Im having the same issue and its hard to find any good workarounds for me. :(

All 6 comments

This issue should be prioritized. Im having the same issue and its hard to find any good workarounds for me. :(

This issue should be prioritized. I'm having the same issue and its hard to find any good workarounds for me. :(

Are you trying to create stepping for a character? I did find a passable workaround, if you want it. I'll put it here regardless, for anyone else who might need it. I'd prefer using an Area for simplicity but:

I used two raycasts childed to my character's rotation node. One is at the step height (I used 0.3), the other is slightly above the ground (I set it at 0.05). I took my input vector, and converted it into a vector3 that could be used as a cast direction for the raycasts (so they always point in the direction the player is trying to move, not just the way they're facing). I then check to see if the player is colliding with a wall, if the bottom raycast is colliding, and the top one is not. If so, do a small jump to get above the step height.

If you play with the raycast lengths (I kept them at 1), they do not appear to trigger on slopes, and the setup also prevents wall climbing. It may not work for stairs, though, I haven't tried it. I would have just used a collider ramp for stairs. If the player is walking up a slope while hugging a wall, it may trigger the jump. Haven't tested.

It's a bit hacky, and if I cared to develop it further, I'd probably just directly set the characters position to the step height, but jumping works and may even be more desirable depending on the game.

image

image

Code snippet:

# member variables:
var stepcast : RayCast
var minstep : RayCast
var stepcast_length = 1
const STEP_SPEED = 4

# references in the _ready function:
stepcast = $CharacterAxis/StepHeight
minstep = $CharacterAxis/MinStep

# Stepping (placed in my input collection function called from _physics_process)
    var cast_vector = Vector3(-input_movement_vector.x * stepcast_length, 0, input_movement_vector.y * stepcast_length)
    stepcast.set_cast_to(cast_vector)
    minstep.set_cast_to(cast_vector)
    if is_on_wall() and not stepcast.is_colliding() and minstep.is_colliding():
        vel.y = STEP_SPEED

I am also having no success with getting an Area to detect a Trimesh StaticBody. Using CollisionShapes would be nicer than RayCasts in many instances, so I hope this is fixed soon.

This seems to have been noted and "fixed" in #16392 and #21744, but it clearly is still an issue in 3.2 master.

I'm trying to get a camera w/ Area sphere to detect collision with a StaticBody terrain.

Terrain sections are made in code from an ArrayMesh. A Shape is generated from the terrain with mesh.create_trimesh_shape(). That is put into a CollisionShape and connected to a StaticBody.

Collision with my KineticBody character and drawing collision debug lines work fine. I don't get the Area::body_entered signal when the Area collides with the terrain.

It will signal with a StaticBody sphere, or if I change the function to mesh.create_convex_shape(). However that does not provide an accurate collision shape.

Raycasts are a reasonable workaround for now.

This seems to have been noted and "fixed" in #16392 and #21744, but it clearly is still an issue in 3.2 master.

From what I can tell, a method for convex collision detection was implemented in #16392. Looking at space_bullet.cpp around line 720 shows that concave collisions are not yet implemented.

The reproduction project in the original post seems to work fine for me in 3.2.3, all three bodies can detect the cylinder fine.
Tested with both Bullet and GodotPhysics.

Was this page helpful?
0 / 5 - 0 ratings