Hi, I would first recommended to download demos from godotengine.org/download
and look at 3d demos.
.....for a character player or npc depends what from are extends RigidBody or KinematicBody but for character not ideal
starts extend from Node.
for example player character :
I have some flying dron - this is a player character in the game
so....player_dron.tscn or scn
- Dron - RigidBody node - attached script for character, control, etc.
- I__dron_collision - Collision shape node
- I__body - Spatial node
- I__body_mesh - Geometry Instance node
- I__body_animation - Animation Player node - anims for character
- I__camera - Spatial node - attached script for 3th person camera
- I__cam - Camera node
- I__pivot - Position 3D node
---------------------------------------------------------------------------------------
....so two scripts for character and camera in this example.
I started with scripting and GDscript not so long ago....so I'm a greenhorn :)
for movement this dron I have this script
extends RigidBody
var speed = 0
var body_speed = 0
onready var main_body = get_node(".") # main body = root node Dron
func _ready():
set_process(true)
set_input_process(true)
set_fixed_process(true)
func _fixed_process(delta):
body_speed = 80
if Input.is_action_pressed("fly_up"):
main_body.set_axis_velocity(Vector3(0, 1, 0) body_speed delta)
if Input.is_key_pressed(KEY_W): or - is_action_pressed("forward"):
speed = speed + 0.1
elif Input.is_key_pressed(KEY_S):
speed = speed - 0.1
if Input.is_key_pressed(KEY_A):
rotate_y(-delta/4.0 * 2*PI)
elif Input.is_key_pressed(KEY_D):
rotate_y(delta/4.0 * 2*PI)
translate(Vector3(0,0,delta*speed))
....off course for a dron must set low gravity - set_gravity_scale(0)
and for a KinematicBody
var t
var r
export var t_speed = 20
export var r_speed = 10
func _process(delta):
t = get_transform()
r = get_rotation()
if(Input.is_action_pressed("forward")):
t.origin += t.basis[2] - t_speed delta
elif(Input.is_action_pressed("backward")):
t.origin += t.basis[2] t_speed delta
if(Input.is_action_pressed("turn_right")):
r += Vector3(0,-1,0) r_speed delta
set_transform(t)
set_rotation(r)
...hope this helps :)