Im very confused as to what is going on

Godot Version

4.4

Question

i made a model on blender and gave it some basic animations,
it has some problems being translated into godot and im not sure what is going on or why is it not working

extends CharacterBody3D


const SPEED = 5.0
const JUMP_VELOCITY = 4.5

@export var D_P := 20
@export var max_Hp := 100
@export var attack_range := 1.5

var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
@onready var navigation_agent_3d: NavigationAgent3D = $NavigationAgent3D

@onready var animation_player: AnimationPlayer = $AnimationPlayer


var player
var provoked := false
var relaxed := true
var agrro_range := 12.0
var Hp: int = max_Hp:
	set(value):
		Hp = value
		if Hp <=0 :
			queue_free()
		provoked = true

func _ready() -> void:
	player = get_tree().get_first_node_in_group("player")

	if relaxed :
		animation_player.play("idle")

func _process(delta: float) -> void:
	if provoked:
		navigation_agent_3d.target_position =  player.global_position

func _physics_process(delta: float) -> void:
	var next_position = navigation_agent_3d.get_next_path_position()
	# Add the gravity.
	if not is_on_floor():
		velocity.y-= gravity * delta


	var direction = global_position.direction_to(next_position)
	var distance = global_position.distance_to(player.global_position)
	
	if distance <= agrro_range:
		provoked=true
	
	if provoked: 
		if distance <= attack_range:
			animation_player.play("attack")
	
	
	if direction:
		look_at_target(direction)
		velocity.x = direction.x * SPEED
		velocity.z = direction.z * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
		velocity.z = move_toward(velocity.z, 0, SPEED)
	move_and_slide()
	

func look_at_target(direction: Vector3) -> void:
	var adjused_direction = direction
	adjused_direction.y = 0
	look_at(global_position + adjused_direction, Vector3.UP, true)

func attack() -> void:
		player.Hp -= D_P

Hi, can you clarify what problems the model is having? It is easier to figure out the issue that way.

yeah, sorry i forgot to upload the video i took

Well, for one thing, your penguin model has its origin at its center. You probably want the origin to be under its feet, so if you put it at y = 0.0 its feet will be on the floor.

how u do that on godot? or i need to go back to blender and do it again?

i think i saw the problem

It may be possible to do it in the import to godot, but it’s probably best to fix the model in blender. It should just be a matter of moving the whole model up.

If you want a quick temporary fix, it looks like that model is 2.7 units tall, and it looks like the origin is roughly in the middle, so if you set position.y = 1.5 it ought to pop it out of the ground, and then the physics ought to solve the rest.

But really, ideally, the fix is to go back to blender and just slide the model up so its feet are standing on the origin, then re-export that.

i was doing some stuff but i will try to change it on blender

i did the changes on blender progress is being made ( i think)

1 Like