summaryrefslogtreecommitdiffstats
path: root/World.gd
blob: c0d224b6f14b182f7dcb8df12cf9528ea602a523 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
extends RigidBody

export var acceleration = 10.0;

func travel(direction:Vector3):
    var boat = $"/root/Main/Raft"
    var boat_direction = boat.global_transform.basis
    boat_direction = Basis(Vector3.UP*boat_direction.get_euler().y)
    direction = -direction
    direction = boat_direction * direction
    direction = direction.normalized()
    self.add_central_force(direction*acceleration)

func _integrate_forces(_state):
    var stick = Input.get_axis("ship_down","ship_up")
    if stick != 0.0:
        travel(Vector3.FORWARD*stick)