Basically, I want to prevent the box, which is set to the collision point of the raycast, from clipping through the walls as shown in the video:
I am using a StaticBody3D, switching to a RigidBody3D makes a weird offset from the raycast, and using linear velocity makes the box go crazy and move incredibly fast. I am also using Jolt physics.
Here is the movement code:
public override void _Process(double delta)
{
var blockPosition = RayCast.GetCollisionPoint() - 0.5f * RayCast.GetCollisionNormal();
FakeBox.Position = blockPosition + RayCast.GetCollisionNormal();
[... rest of the code]
}
First of all: When you move physics-objects you always want to do that in _physics_process and not _process.
Second: to reduce the speed of the box you can reduce either the speed or multiply it by delta.
Third: Maybe you can use a shapecast3d. It saves all the collisions so you might be able to stop it from clipping, but im not 100% sure
shapecast3d makes the box go even crazier in terms of position, and the clipping problem still exists. i have moved to physics_process, but can’t really times it by delta when the position is a Vector3
that would technically “fix” the problem, but it causes a whole new one where the movement goes crazy as it’s being pushed against the wall, i kinda tried this with linearvelocity being set instead, but as i said the movement goes crazy