#Big problem

1 messages · Page 1 of 1 (latest)

jagged ridge
severe condor
#

What's the code like?

jagged ridge
#

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

bold berry
#
  1. Don't use chat gpt, learning by yourself is much better than using an AI
  2. velocity.y -= GRAVITY * delta should be velocity += get_gravity() * delta and velocity.y = 0 should get removed
jagged ridge
#

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

bold berry
#

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

jagged ridge
#

yea i was searching for one but didnt find

severe condor
#

Well I copypasted that code and made a test project, and it works alright.
Probably some other setting is off.

bold berry
#

Remove the current script from your CharacterBody3D, add a new one and there should be an option to use a template

severe condor
#

(other than SPEED, which was missing, so I added const SPEED = 5.0)

bold berry
jagged ridge
#

i am unable to select

severe condor
#

Yea can't be selected for an existing script, only a new one

jagged ridge
#

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

severe condor
#

You can just select a MeshInstance node and this button will appear in top bar.

Don't need to add them in code.

jagged ridge
#

where can i find it?

severe condor
#

It only appears while a MeshInstance Node is selected

jagged ridge
#

yea i found it

#

also this is the node tree for the scene i imported from blender

severe condor
#

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.

jagged ridge
#

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

severe condor
#

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.

jagged ridge
#

and i do not see trimesh

severe condor
#

That's where I usually set that. Though you can also keep mesh as separate and make your own collider setup if you wish.

severe condor
# jagged ridge

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.

jagged ridge
#

but for me it says "Mesh is empty"😭

severe condor
#

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?

jagged ridge
#

omg yea

#

what mesh do i ned to set it as

#

bro you are genious

severe condor
#

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.

jagged ridge
#

ooo okay

#

now i created a trimesh and this appeared

severe condor
#

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)

jagged ridge
#

thats the one

#

what is the fix

severe condor
#

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

jagged ridge
#

okay i will try the first one

#

and what shape do i put as collision?

severe condor
#

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.

jagged ridge
#

i do not have a generated shape

severe condor
#

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.

jagged ridge
#

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

severe condor
#

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.

jagged ridge
#

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?

severe condor
#

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.

jagged ridge
#

oh my God it workedddd

#

yay

#

yeaaah man

#

im so thankful

#

i owe you one

severe condor
#

Hey no problem, game dev is hard to learn haha

jagged ridge
#

im actually making real games and i modeled them in blender but couldnt make it work here

#

okay have a good day!