Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | EnesMalik02 |
[My project link] 1
Imgur: The magic of the Internet (this is what i want)
Imgur: The magic of the Internet (this is how it happens)
extends KinematicBody
var speed = 20.0
var velocity = Vector3(0,0,0)
const SPEED = 5
const ROTATION = 3
const GRAVITY = 10
const JUMP = 500
var roketHiziUP = 10
onready var roket = $Cube003
func _ready():
pass
func _physics_process(delta):
if Input.is_action_pressed("ui_up"):
velocity.y += GRAVITY * delta
velocity = move_and_slide(velocity, Vector3.UP)
elif Input.is_action_pressed("ui_right"):
roket.rotate_z(deg2rad(-ROTATION))
elif Input.is_action_pressed("ui_left"):
roket.rotate_z(deg2rad(ROTATION))
elif Input.is_action_pressed("ui_down"):
pass
else:
move_and_slide(Vector3(0,-roketHiziUP,0))
I’m not very good with 3D but, but I think you want to have velocity going forward which is Vector3(0,0,-1)
or Vector3.FORWARD
. The way your code is, right now, it looks like you’re only using the y-axis (up/down) for both gravity and direction of movement. So, redefining your velocity variable at the beginning and maybe the move_and_slide vector at the end should make it better.
The gravity is pushing down and the -roketHiziUP pushing up… surprised it moves at all… So, maybe using the Vector3 constants would make it more clear:
Vector3 — Godot Engine (3.5) documentation in English
● FORWARD = Vector3( 0, 0, -1 )
Forward unit vector. Represents the local direction of forward, and the global direction of north.
CassanovaWong | 2022-09-02 13:28