#Big problem
1 messages · Page 1 of 1 (latest)
What's the code like?
okay here is the code:
const GRAVITY = 9.8
const JUMP_FORCE = 6.0
func _physics_process(delta):
# Гравитация
if not is_on_floor():
velocity.y -= GRAVITY * delta
else:
velocity.y = 0 # Зануляваме вертикалната скорост, когато сме на пода
# Движение с WASD
var input = Vector2(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
)
var direction = (transform.basis * Vector3(input.x, 0, input.y)).normalized()
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
move_and_slide()
there are comments made by gpt i dont think they are the problem
can you help me please noone has helped me since the morning
idk where you live but here is 4pm
- Don't use chat gpt, learning by yourself is much better than using an AI
velocity.y -= GRAVITY * deltashould bevelocity += get_gravity() * deltaandvelocity.y = 0should get removed
thanks 1. is a good idea but i need to make it fast cause i wont get much time later
and also i tried 2. but same effect
Right, but chat gpt is what is causing these issues, you are spending longer debugging than actually learning
Also, you can just use a template
yea i was searching for one but didnt find
Well I copypasted that code and made a test project, and it works alright.
Probably some other setting is off.
Remove the current script from your CharacterBody3D, add a new one and there should be an option to use a template
(other than SPEED, which was missing, so I added const SPEED = 5.0)
Yea can't be selected for an existing script, only a new one
okay yea
same effect...
is it possible for the problem to occur because of the script for collision
extends Node3D
func _ready():
for child in get_tree().get_nodes_in_group("auto_collision"):
if child is MeshInstance3D and not child.get_node_or_null("CollisionShape3D"):
var shape = BoxShape3D.new()
var collision = CollisionShape3D.new()
collision.shape = shape
var aabb = child.get_aabb()
shape.size = aabb.size
var static_body = StaticBody3D.new()
static_body.name = "AutoStaticBody"
static_body.transform.origin = aabb.position + aabb.size * 0.5
static_body.add_child(collision)
child.add_child(static_body)
print("✅ Added collision to:", child.name)
i added this because the scene is imported from blender and i needed collision
You can just select a MeshInstance node and this button will appear in top bar.
Don't need to add them in code.
where can i find it?
yea i found it
also this is the node tree for the scene i imported from blender
Here's what a corner piece I made it Blender looks like for me.
The CollisionShape3D was created after I selected the MeshInstance node and clicked the button and told it to make a trimesh from the mesh.
Here's what it generated from my mesh.
Although for simple shapes like flat floors I usually just manually place the existing colider shapes, they are more efficient than mesh colliders.
so what do i need to click now? im on godot 4
and when i drag my .glb from blender it doesnt place as static body
If your MeshInstance node has a mesh from Blender, pressing the button in top bar should allow you to make a trimesh.
Anyway yeah I usually right click my .glb and select "new inherited scene" isntead of using just the glb directly.
And in the glb file's import settings there's a button to select the type of the root node.
That's where I usually set that. Though you can also keep mesh as separate and make your own collider setup if you wish.
If you click on Create Collider mesh it'll make you a collider. If the MeshInstance Node has a mesh.
And one of the options in the menu that appears is trimesh.
Well it'll only work if it has the actual mesh.
You seem to have at least two mesh instance nodes, so maybe you chose one that doesn't have a mesh?
It'll make a collider for whatever mesh it's given.
Like if you make a pyramid in Blender then the mesh instance node on import will have that pyramid.
And that create collider thing will just create a collider in same shape as the mesh.
Yeah if you click on that yellow triangle it'll probably warn that a collisionshape node needs to be a child of a physics shape (like static body or character body)
Yeah you can either make a new staticbody node and put that collision shape as it's child, or convert it's current parent ndoe into one.
Either one is fine
Well if you used the generate button it'll make you a collision shape that has a trimesh of that shape as collision.
But for simple ones you can put in a cube and just resize it manually if you want.
Oh. That's really weird.
Mine looks like this, before and after.
Maybe it doesn't like the way your Nodes are ordered or... I don't actually know.
oh daym
thats gonna be a problem in the future
perhabs i should use other engine such as unreal engine or unity?
i am very thankful for the time you spend with me sir
i wish you to have a nice day
What I usually do with my walls/floors etc. is I right click the .glb and make an inherited scene.
And then make the colliders and stuff there and save it. And add that saved scene.
But yea dunno what's wrong with yours.
And ye I used Unity before I learned Godot, it's not too hard to learn either tbh.
oh it really did something different
i may have possibly found a solution then
this is what it looks like now
this is where i got it to
where do i need to put a static body 3d?
okay i added it but how to import the scene into my main one?
You can save the scene and it'll become a .tscn file. And you can just drag it to an another scene with your mouse.
Also if you edit the .tscn it'll update all of them. So you can have like 200 walls and have all of them update when you edit that one scene.
Hey no problem, game dev is hard to learn haha