Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Sojan | |
Old Version | Published before Godot 3 was released. |
Hey everyone, I am a complete beginner in game scripting. I can handle most 3d stuff, textures, and gui, but I just can’t get the scripting right. I am trying to get a 3d kinematic character script for third person. Basically, I want it to be able to do this:
extends KinematicBody
var t
var r
export var MSpeed = 10
export var RSpeed = 10
func _process(dt):
t = get_transform()
r = get_rotation()
if(Input.is_action_pressed("ui_up")):
t.origin += t.basis[2] * -MSpeed * dt
if(Input.is_action_pressed("ui_down")):
t.origin += t.basis[2] * MSpeed * dt
if(Input.is_action_pressed("ui_right")):
r += Vector3(0,-1,0) * RSpeed * dt
elif(Input.is_action_pressed("ui_left")):
r += Vector3(0,1,0) * RSpeed * dt
set_transform(t)
set_rotation(r)
func _ready():
set_process(true)
But with gravity, and collision detection. Is there any easy way? Or a tutorial that shows how?