Godot Version
4.2.1
Question
So I am making a game where you play as a cube and when you collide with another cube (there will be several scattered around), the cube sticks to you. When you press a button you let go of the cube. The cube should stick to you from any side, but I don’t know how to do this. Could somebody please help me?
this 3d or 2d?
also it does sounds like if you are using rigidbody, you will freeze the cube attached to you when it touched your cube
also move the cube to as your child before that, while preserving the position where it touched
Yes, it’s 2D, sorry forgot so say that.
I am using a CharacterBody2D, should the other cubes also be those?
if that’s so, then you will need to stop the _physics_process of the cube attached to you to false or anything that wont trigger the move_and_slide(), so it will looks like freeze in mid air when touching your cube
In the prgoramming sort of things, do you what code should I write to make it so it sticks to the player cube?
it basically tell the body to set_physics_process(false) upon collision
there should be many other ways, it’s just one of them i knew how to make it stick similar to making it freezes on rigidbody
but since only freezing it just stop the movement and wont follow the player’s cube. the player cube should have a node to store as a parent for this newly sticked cubes, so it follows the player around
add the cube as a child of the character so its position sticks. Also turn off the cubes physics so it doesnt move locally.
So I did make it as a child, both are CharacerBody2D. I turned of the child’s physics by adding a script with this to it:
func _ready():
set_physics_process(false)
It still moves with the parent cube.
I just want to make a simple cube that if you run into it sticks to you and then you can make it unstick from you by pressing a button.