Godot Version
v.4.7.2.stable.official
Question
Good day.
I am having trouble with my racing project, but before I get into it, there is something I need to explain first.
This is my first project in the godot, I decided to make this project as a means to familiarize myself with the engine and so I am still very likely to make mistakes.
Now that I’ve made this clear, I am going to explain this issue to the best of my extent, but you are free to ask questions if necessary.
I have attached two GPUParticle3D instances to the rear wheels of my vehicle (with local cords enabled), as children of their respective VehicleWheel3D instances.
I’ve made an attempt to emit these particles at set periods (temporarily removed for testing purposes) and I found these particle instances emitting from what seems to be the spawn point of my vehicle, split apart as if they fell from the wheels of the vehicle.
I cannot move them, I have tried to re-parent these particles, and also the VehicleBody3D itself, setting the VehicleBody3D to root node does not make a difference and seems to break my camera functionality, I cannot explain why.
I do not know where I can fix this, but I believe this might be an issue elsewhere, not involving the particle instances.
Any help is much appreciated.
Thank you.
Main Scene Tree:
Scene (Node3D)
\_ Vehicle (Scene)
\_Environment (Node3D)
\_CSGBox3D
\_DirectionalLight3D
\_WorldEnvironment
Vehicle Scene Tree:
Vehicle (Node3D)
\_VehicleBody3D
\_Body_Mesh (CSGBox3D)
\_CollisionShape3D
\_RRWheel (VehicleWheel3D)
\_RRWheelMesh (CSGCylinder3D)
\_RRWheelSmoke (GPUParticle3D)
\_RLWheel (VehicleWheel3D)
\_RLWheelMesh (CSGCylinder3D)
\_RLWheelSmoke (GPUParticle3D)
\_FRWheel (VehicleWheel3D)
\_FRWheelMesh (CSGCylinder3D)
\_FLWheel (VehicleWheel3D)
\_FLWheelMesh (CSGCylinder3D)
\_Center_O_M
\_Camera_O_P
\_Camera3D
Script:
`extends VehicleBody3D
#Variables
@export var Power: float = 0
@export var Max_Steer_Angle: float = 0.0
@export var Turning_Wheel_Force: float = 0.0
@export var Normal_Rear_Wheel_Traction: float = 0.0
@export var Turning_Rear_Wheel_Traction: float = 0.0
@export var Drift_Force_Strength_Multiple: float = 0.0
@export var Max_Drift_Force: float = 0.0
@export var Break_Force: float = 0.0
@onready var cam_o_p: Node3D = $Cam_O_P
@onready var camera_3d: Camera3D = $“../Camera3D”
@onready var rr_wheel: VehicleWheel3D = $RRWheel
@onready var rl_wheel: VehicleWheel3D = $RLWheel
@onready var fr_wheel: VehicleWheel3D = $FRWheel
@onready var fl_wheel: VehicleWheel3D = $FLWheel
@onready var rr_wheel_smoke: GPUParticles3D = $RRWheel/RRWheel_Mesh/RRWheel_Smoke
@onready var rl_wheel_smoke: GPUParticles3D = $RLWheel/RLWheel_Mesh/RLWheel_Smoke
func _physics_process(delta: float) → void:
#Steering Physics
steering = move_toward(steering, Input.get_axis(“Right”, “Left”) * Max_Steer_Angle, delta * 4)
#If player is turning left, increase right rear wheel power and traction
if steering > 0 and linear_velocity.dot(global_transform.basis.z) > 0:
rr_wheel.engine_force = Turning_Wheel_Force
rr_wheel.wheel_friction_slip = Turning_Rear_Wheel_Traction
#Add a force to the left side going right at high velocity for ease of drifting
if linear_velocity.dot(global_transform.basis.z) >= 30:
apply_force(Vector3(clamp(-linear_velocity.dot(global_transform.basis.z) * Drift_Force_Strength_Multiple,-Max_Drift_Force,0),0,0), Vector3(0,0,-1))
#Stop the force if player is no longer at high velocity
else:
pass
#Reset rear right wheel power and traction values if player stops turning
else:
rr_wheel.engine_force = engine_force
rr_wheel.wheel_friction_slip = Normal_Rear_Wheel_Traction
#If player is turning right, increase left rear wheel power and traction
if steering < 0 and linear_velocity.dot(global_transform.basis.z) > 0:
rl_wheel.engine_force = Turning_Wheel_Force
rl_wheel.wheel_friction_slip = Turning_Rear_Wheel_Traction
#Add a force to the right side going left at high velocity for ease of drifting
if linear_velocity.dot(global_transform.basis.z) >= 30:
apply_force(Vector3(clamp(linear_velocity.dot(global_transform.basis.z) * Drift_Force_Strength_Multiple,0,Max_Drift_Force),0,0), Vector3(0,0,1))
#Stop the force if player is no longer at high velocity
else:
pass
#Reset rear left wheel power and traction values if player stops turning
else:
rl_wheel.engine_force = engine_force
rl_wheel.wheel_friction_slip = Normal_Rear_Wheel_Traction
#Engine Physics
engine_force = Input.get_axis(“Backward”, “Forward”) * Power
#Camera Physics
camera_3d.global_position = camera_3d.global_position.lerp(cam_o_p.global_position, delta * 20)
camera_3d.global_rotation.y = global_rotation.y -PI`
PS: I am aware that the drift force is applied at high velocity even if player is not accelerating, I am will tend to this issue later.