Godot Version
4.2.2 Stqble
Hello all,
I’m new to Godot. Actually tried it a few year ago probably some version two.
Now as as “Hello World” project I’m recreating Space Taxi from the good old C64 days. I’m using node_3d for this since I want to expand the 3D stuff later.
Now I had everything running fine when I started to alter the taxi model in Blender. Then things went south.
Basically I just have a quite simple model for a taxi. A yello box with a few edges. I exported the model from blender to a glb file and use the import function in Godot. I imported the “Taxi1.glb” file as CharacterBody3D. The model also has a cube-colonly which the importer detects as CollitionShape3D. Then I save the imported model as taxi_1.tscn. But when inserting it into my Node3D it complains that the node has no shape. So it does not recognize the CollitionShape3D I guess. Because it I create one the warning disappears .
Also now the movements of the Taxi is totally weir. While it was good some imports a go.
The script is really simple. The game actually is on the Y and Z axis. I’ll change that later to be X and Y.
extends CharacterBody3D
const SPEED = 0.5
const DRAG = 1.0
const JUMP_VELOCITY = 1.5
var taxiDirection = "Left"
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle jump.
if Input.is_action_pressed("ui_up"): # and is_on_floor():
velocity.y += JUMP_VELOCITY
if Input.is_action_pressed("ui_down"):
velocity.y -= JUMP_VELOCITY
if Input.is_action_pressed("ui_right"):
velocity.z -= SPEED
if taxiDirection == "Left":
taxiDirection = "Right"
rotate_y(deg_to_rad(180))
if Input.is_action_pressed("ui_left"):
velocity.z += SPEED
if taxiDirection == "Right":
taxiDirection = "Left"
rotate_y(deg_to_rad(-180))
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
# var input_dir = Input.get_vector("ui_left", "ui_right", "ui_accept", "ui_down")
# var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# if direction:
# velocity.x = direction.x * SPEED
# velocity.z += direction.z * SPEED
# else:
# velocity.x = move_toward(velocity.x, 0, SPEED)
#velocity.x = move_toward(velocity.x, 0, DRAG)
#velocity.y = move_toward(velocity.y, 0, DRAG)
velocity.z = move_toward(velocity.z, 0, DRAG)
move_and_slide()
My impression is that something in the background is also acting on the movement of the Taxi object but I can’t find out what it could be.
Thank you for any suggestions on how I could solve this.