I want to make that the player can lift an object with the mouse in a certain radius. For this I have created an object that aligns from the player to the mouse and the movable object is positiooned on that line.
Red object: object to pick up
Black object: Player
White line: Radius in which the object can be picked up
The problem is that I don’t want the red object to be able to pass through the walls or the floor. My idea would be to adjust the length of the white distance object to the collision with grond/wall. Is this possible or do you have a better idea?
The red object has the physics behavior so that you can throw the object.
Hi, sounds like a raycast is what you need here. Unfortunately it is not well documented but you can figure out how it works by looking at this example GDevelop 5 and by reading this explanation: [Solved] Raycast - #2 by ddabrahim
If you’re already using the physics behavior then you can also assign the physics to the floor and wall. Just set the type to static so they don’t fall. You can then change how the objects interact.
How are you constraining the object? I’m not sure if you’re aware of the Physics Rope joint. It seems perfect for your situation. It takes a 2nd object and just a one-time action to setup. You can change the length later using it’s ID.
Here’s an example using a hidden object in between the ball and mount to make the rope look a little more real. You can create a chain look as well. I believe there’s an example.
Try it:
The ball and controlPoint both have physics, you can tweak the settings or use default. The walls have a physics behavior with type set to static. There’s a slider, toggle button and ShapePainter with relative to object position unchecked and fill opacity set to zero.