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.