How to make a grabbing system in GODOT 4.0 (LINK IN DESC)

  Рет қаралды 10,034

OneCent

OneCent

Күн бұрын

Пікірлер: 32
@Ultimite_
@Ultimite_ Жыл бұрын
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
@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_
@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
@cent1111 Жыл бұрын
@@Ultimite_ Yea, a followup would be a great idea, thanks for the video idea xD!
@Cr-kz1mp
@Cr-kz1mp 3 ай бұрын
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
@chantolove
@chantolove 5 ай бұрын
wow, the editing makes this almost impossible to understand
@NyandogsChannel
@NyandogsChannel 4 ай бұрын
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
@cent1111
@cent1111 4 ай бұрын
Nice, i already did this in my latest video
@ImSim_Cook
@ImSim_Cook 6 ай бұрын
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_Cook
@ImSim_Cook 6 ай бұрын
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
@cent1111
@cent1111 6 ай бұрын
@@ImSim_Cook oh actually, there is no gravity, i made a mistake whilst declaring the variables, sorry!
@cent1111
@cent1111 6 ай бұрын
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_Cook
@ImSim_Cook 6 ай бұрын
@@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
@cent1111
@cent1111 6 ай бұрын
@@ImSim_Cook oh ok, maybe in future tutorials, i wont just say "copy me", i might make a in depth explanation! 😃
@P0REBR1CK
@P0REBR1CK Ай бұрын
What to do if is_in_group() not working? (I use godot 4.3)
@cent1111
@cent1111 Ай бұрын
it should work, it returns a boolean value
@P0REBR1CK
@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
@cent1111 Ай бұрын
@@P0REBR1CK show me your code
@UmarO
@UmarO 8 ай бұрын
my raycast3d collides with the csgcombiner i have for the floor, not the rigidbody3d box i made. Any idea why?
@ImSim_Cook
@ImSim_Cook 6 ай бұрын
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?
@cent1111
@cent1111 6 ай бұрын
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_Cook
@ImSim_Cook 6 ай бұрын
@@cent1111 makes total sense! However I didn’t even see a camera node in the scene tree. Was that just later on?
@cent1111
@cent1111 6 ай бұрын
@@ImSim_Cook yes i think so,
@porkyorcy1715
@porkyorcy1715 10 ай бұрын
🤣 quickest tutorial ever, thank u
@cent1111
@cent1111 9 ай бұрын
Your welcome
@thecringeslayer4897
@thecringeslayer4897 7 ай бұрын
absolute legend
@Devlopergabut
@Devlopergabut 7 ай бұрын
Bro, what button to take the object has to be set in the project settings, so what is the button there?
@cent1111
@cent1111 7 ай бұрын
In this project, we actually use the is_key_pressed() function, read the code for the graber more careful at the start
@alexxander7289
@alexxander7289 3 ай бұрын
14 seconds.
@VladQc
@VladQc 8 ай бұрын
damn. thats good
@cent1111
@cent1111 8 ай бұрын
thanks
Jiggle Physics in Godot
13:31
CoderNunk
Рет қаралды 91 М.
I Was Making Enemies Completely Wrong
17:06
Deynum Studio
Рет қаралды 195 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Mirrors, Every Way You Can Make Them In A Video Game
8:14
Code It All
Рет қаралды 68 М.
4 Reasons Why You Should Use Jolt Physics (Godot 4)
3:54
PiCode
Рет қаралды 32 М.
How to make Pickup and Drop System Easily in Godot - 4 mins
4:19
Interact With Objects in Godot 4 | Let's Godot
10:39
DashNothing
Рет қаралды 70 М.
The 4 MUST Have ADDONS for Godot 4
4:02
DevWorm
Рет қаралды 92 М.
Basic Inventory System [Part 1] - Godot 4.x
12:02
Bonkahe
Рет қаралды 6 М.
What does a Game Engine actually do?
16:45
Ellie Rasmussen
Рет қаралды 176 М.
How You Can Easily Make Your Code Simpler in Godot 4
6:59
Bitlytic
Рет қаралды 487 М.
choosing a game engine is easy, actually
15:08
samyam
Рет қаралды 648 М.
How Games Make VFX (Demonstrated in Godot 4)
5:46
PlayWithFurcifer
Рет қаралды 369 М.