Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+6 votes

How am I able to make my player, which is a characterbody2d move a large box lets say, I have a collision shape on it, check and see if a signal touches and what not however it isn't moving obviously. Do I need to add some sort of physics setting to it?

asked in CSC380Jan2024 by (2k points)

4 Answers

+2 votes

maybe make the box a rigid body and have a collide function for it

answered by (2.4k points)
+2 votes

Make sure you are applying force or setting the box's velocity obviously. Also check collission layers. If the player or box are not looking for each other nothing will happen. And then also check what node your using. You might have to do some research on what node type will work. my guess would be a body type opject like player, rigid, static, etc.

answered by (3.8k points)
+2 votes

Any chance you can post your script so we can look at it?

answered by (2.1k points)
+1 vote

I would suggest you to attach a RigidBody2D node to the large box. Add a CollisionShape2D to the RigidBody2D to define the shape of the box. Then you should attach a KinematicBody2D or CharacterBody2D node to your player. Make sure both the player and the box have proper collision layers and masks set up. Then you connect the body_entered signal from the player to a script. In the script attached to your player, you can use the move_and_slide or move_and_collide functions to move the player. When the player collides with the box, you can use the information from the body_entered signal to apply forces to the box.

answered by (3k points)
...