Basic Godot Movement 2.5D (Absolute Beginner) Question

Here’s the problem. I wanted to do this:

[https://www.youtube.com/watch?v=TBGX77yKRgw&t=43s]

Or this:

[https://www.youtube.com/watch?v=QJPfkkVCAPI&t=304s]

But I want the character to rotate 360 ​​degrees while jumping and kill the enemy (like Sonic). It is possible to do this through Animation Player, but I won’t do that. I want the Kinematic Body to rotate, and then it’s easy to replace it with Mesh. I don’t know anything about coding, I tried to get the code via ChatGPT, here’s what I got:

extends KinematicBody

export var speed = 14
export var fall_acceleration = 200
export var jump_impulse = 34
export var rotation_speed = 800

var velocity = Vector3.ZERO
var is_jumping = false
var rotation_on_jump = 0

func _physics_process(delta):
var direction = Vector3.ZERO

if Input.is_action_pressed("move_right"):
	direction.x += 1
if Input.is_action_pressed("move_left"):
	direction.x -= 1
if Input.is_action_pressed("move_back"):
	direction.z += 1
if Input.is_action_pressed("move_forward"):
	direction.z -= 1

if direction != Vector3.ZERO:
	direction = direction.normalized()

# Skakanje.
if is_on_floor() and Input.is_action_just_pressed("jump"):
	is_jumping = true
	velocity.y = jump_impulse

# Rotacija tokom skoka oko z ose.
if is_jumping:
	var target_rotation = direction.angle()
	var current_rotation = rotation.y
	rotation.y = lerp_angle(current_rotation, target_rotation, rotation_speed * delta)

# Kretanje.
velocity.x = direction.x * speed
velocity.z = direction.z * speed
velocity.y -= fall_acceleration * delta

# Provera kolizije sa objektima.
velocity = move_and_slide(velocity, Vector3.UP)

The code partially works, but it took me five days to explain to the retarded AI what I wanted. I looked everywhere for a solution. It took me 6 months to collect the money to buy your course at a discount. Let’s see if it’s worth it. I need someone to write me the code, or better yet make a video. I apologize for the long post. I hope it’s accurate enough, so if anyone can help I’d be very grateful. I can repay with some 3d model or animation. Thank you for understanding and reading.

Why are you against using the AnimationPlayer? Just trying to understand your situation better, because I’ve literally done exactly what you’re asking, and the AnimationPlayer did it perfectly.

Ok. This does seem sound at first glance; what exactly are you experiencing that you don’t like about it?

I can appreciate your frustration - believe me, I’ve been there plenty of times - but do try not to take it out in your posts. Learning any language involves wading through some growing pains, especially when you have ambitions that you want to do right away. It takes time =)

The code is partially working. When I say that, it means that I can’t get ChatGPT to correct the code. The character does not turn its face in the given direction, and when jumping, it does not turn in the direction of movement. It only rolls over in one direction. If I give this code to AI it gives me another one full of errors. I don’t know anything about GDscript. As for Animation player, my opinion is that it is a totally wrong approach. The programmer should do his part, not: “The animator will do that.” And in the end, when something is learned, it should be the pleasure of learning and not frustration after frustration, such as I have had in the last year. The only thing that keeps me going is that someone will appear with a simple solution to this problem. I even tried to offer a percentage for the code, but nothing. No developer would take 15 minutes to do this. I don’t believe it needs more time. Everyone pretends to be smart. In any case, thanks for the answer.

Well, good luck to you.

The way you’re feeling is no fun; I genuinely hope you find some peace in the future.

hi Zoran,

just wondering, you mentioned you got one of the godot courses? which one may i ask.

im only thinking about what course you got as the beginner godot courses would walk through gd script to a quite reasonable beginner level. which would give you the confidence and a solid grounding in the godot coding and practice side and be able to slowly pick apart the script that the AI would give you and be able to follow it to a reasonable level.

ive not done anything similar to this. but if your working through a godot course, then as you become more familiar with it and branching out on your own projects, breaking some of the things you want to happen down into bite size parts and work on the smaller things to eventually make a whole.

AI can be good sometimes for explaining some parts or code snippits, but getting it to provide a whole bespoke script can be troublesome and not always what you are looking for. but thats only been my personal experience.

i think from my thoughts, if the movement is working in 3 dimensions cool, the next step to figure out would be getting the character to face the same way as the movement vector.
once you have the character facing the right direction you can use the vector that is at right angles to that to rotate around.

for example, just off the top of my head, if you have the direction vector, you could use the look_at() method to point the local positive Z direction of the player in that direction.

for the rotation, since Z is now pointing foward, the models local X axis would be perpendicular so the rotation could be done around that axis. and Y is just the up and down that keeps the player upright.

hopefully you can get some takeaway from that that will help you dig a little deeper.

Darren

1 Like

I bought this course:

Udemy course

But the examples I listed above are from YouTube. Looks like I wasted my money. I managed to combine this code from multiple videos and AI.

It’s not worth digging around on the internet, I’m slowly giving up. It seems that what I imagined is doomed. At the very beginning, I encountered a big obstacle, and what will happen to the other obstacles.

For example: In the game, the character has to swing on a liana and switch hands on it. I can’t find that anywhere either.

The only thing is that the game should be 2d. And there would be problems, I’m sure.
Never mind, we’ll see how things go.

Maybe someone will show up with a solution, who knows?

awesome, i loved it and learned alot as well,

dont give up please, go through the course it does have a heck of alot of brilliant information and learning material from coding to godot best practices.

I will watch the course first, I will not say anything in advance. I was hoping to find Bram here and he would explain this problem to me.

Maybe on Udemy he will accept to do video on demand.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms