small racing game im working on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class_name CarVars
extends Resource

var throttle: float
var brake: float
var steering: float
var engine_force: float
var engine_rpm: float
var wheel_rpm: float
var wheel_skidinfo: Array
var wheel_contact: Array
var wheel_position: Array
var current_gear: int
var position: Vector3
var rotation: Vector3
var kph: float

func _init(from: Car) -> void:
		throttle = from.throttle
		brake = from.brake
		steering = from.steering
		engine_force = from.engine_force
		engine_rpm = from.engine_rpm
		position = from.global_position
		rotation = from.global_rotation
		kph = from.kph()
		for i in from.wheels.size():
				var wheel := from.wheels[i]
				wheel_skidinfo.append(wheel.get_skidinfo())
				wheel_contact.append(wheel.is_in_contact())
				wheel_position.append(wheel.global_position)

func to_dict(): # RIP memory
		return {
				throttle = throttle, brake = brake, steering = steering,
				engine_force = engine_force, engine_rpm = engine_rpm,
				position = position, rotation = rotation, kph = kph,
				wheel_skidinfo = wheel_skidinfo, wheel_contact = wheel_contact,
				wheel_position = wheel_position,
		}