3d Kinematic character rotation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sojan
:warning: 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?

:bust_in_silhouette: Reply From: puppetmaster-

try to do it in _fixed_process() not in _process()

func _fixed_process(delta):
    set_transform(t)
    set_rotation(r)

func _ready():
    set_fixed_process(true)

But that is not going to add physics, or kinematics, is it?

Sojan | 2016-06-29 13:02

Automatic physics you only get with a rigidbody.

In a kinematicbody you need to programmatic simulate your own.

Some 3D physic tutorials Godot Engine: Roll A Ball Tutorial

puppetmaster- | 2016-06-29 19:05

All right yes thanks. I have already followed the tutorial (downloaded the series on my hard drive;)), however, being a complete beginner, I’m having a hard time too repurpose the controller to my specifications. And I couldn’t find a conclusive to tutorial for 3d kinematic bodies.

Sojan | 2016-06-30 02:30