Holy smokes this code works. I've been looking for a way to grab physics object in game for a while now and you sir are a legend. Only problem I've noticed is that when a rigidbody is picked up it's downwards velocity is increasing while in the air, but that makes sense as we're only moving an object around.
@cent1111 Жыл бұрын
Thanks for the feedback! One way that the RigidBody problem could be fixed is that every frame, when the variable "obj" isnt equal to "null", check if obj is a rigidbody, then if it is, set its LinearVelocity property to Vector3.ZERO, Maybe ill make a video into more explanation for grabbing.
@Ultimite_ Жыл бұрын
@@cent1111 wow that is significantly smarter and easier than the dumb idea I tried getting to work with linear and angular velocity being reset when the player lets go of the grab button, then trying to get a way to detect that an object is no longer being held... somehow XD. A video on grabbing RigidBody3D nodes and maybe throwing them would be a cool follow up.
@cent1111 Жыл бұрын
@@Ultimite_ Yea, a followup would be a great idea, thanks for the video idea xD!
@Cr-kz1mp3 ай бұрын
it's just easy, first make var 'which is coliding' = null than check if raycast3d is coliding inside make a condition if raycast3d.get_colidier is rigdit body 3d : which coliding = raycast.get_colider which colider.global_position = holder.global_position #how to unhold the object? if input.is action just pressed("ui_accept"): which coliding = null importent notice! check the raycast have colision mask two and which colidier physic layer assain two! plz give me A like
@chantolove5 ай бұрын
wow, the editing makes this almost impossible to understand
@NyandogsChannel4 ай бұрын
I have written this, its more source - like and does not ignore collisions for rigidBodies if collider != null && (collider.is_in_group("CARRY") && collider.is_class("RigidBody3D")) && Input.is_action_pressed("carry"): obj = collider if obj: var direction : Vector3 = obj.global_transform.origin.direction_to($"../CarryPoint".global_transform.origin) var force : float = obj.global_transform.origin.distance_to($"../CarryPoint".global_transform.origin); if (force > 0.6): force = 0.6 obj.linear_velocity = obj.linear_velocity * 0.95 obj.apply_central_impulse(direction * force) if Input.is_action_just_released("carry"): obj = null
@cent11114 ай бұрын
Nice, i already did this in my latest video
@ImSim_Cook6 ай бұрын
okay another question cause as a relative beginner I'm super interested in how you did a lot of this stuff. what is your reasoning for coding player movement the way you do? as opposed to the native characterbody scripting for it.
@ImSim_Cook6 ай бұрын
also, in which line are you calculating gravity? I saw the variable but didn't see where it was being applied. I wanna adopt this method of coding movement but just wanted to understand it and not copy paste
@cent11116 ай бұрын
@@ImSim_Cook oh actually, there is no gravity, i made a mistake whilst declaring the variables, sorry!
@cent11116 ай бұрын
this is not a good character body movement script as i just made it as a simple quick, quite crappy script, so this is not a real movement you should use
@ImSim_Cook6 ай бұрын
@@cent1111 I gotcha! I just hate using a prewritten script. I want to dig in and actually write it all out and the idea of using something more like an array looked cool
@cent11116 ай бұрын
@@ImSim_Cook oh ok, maybe in future tutorials, i wont just say "copy me", i might make a in depth explanation! 😃
@P0REBR1CKАй бұрын
What to do if is_in_group() not working? (I use godot 4.3)
@cent1111Ай бұрын
it should work, it returns a boolean value
@P0REBR1CKАй бұрын
@cent1111 idk what to do, because code is working yes, but this code is ignoring, i try to pick up object on E, but nothing, i too added block what i want pick up to the group, and i write group what i want to grab, but nothing :(
@cent1111Ай бұрын
@@P0REBR1CK show me your code
@UmarO8 ай бұрын
my raycast3d collides with the csgcombiner i have for the floor, not the rigidbody3d box i made. Any idea why?
@ImSim_Cook6 ай бұрын
I know I’m just being blind and dumb so please feel free to call me both but are you/how are you doing your character controller with no camera and head nodes?
@cent11116 ай бұрын
oh actually, instead of rotating the camera, for the sake of a simple fast script, i just rotate the entire player, whilst the camera is looking forward inside of the player
@ImSim_Cook6 ай бұрын
@@cent1111 makes total sense! However I didn’t even see a camera node in the scene tree. Was that just later on?
@cent11116 ай бұрын
@@ImSim_Cook yes i think so,
@porkyorcy171510 ай бұрын
🤣 quickest tutorial ever, thank u
@cent11119 ай бұрын
Your welcome
@thecringeslayer48977 ай бұрын
absolute legend
@Devlopergabut7 ай бұрын
Bro, what button to take the object has to be set in the project settings, so what is the button there?
@cent11117 ай бұрын
In this project, we actually use the is_key_pressed() function, read the code for the graber more careful at the start