22 lines
552 B
GDScript3
22 lines
552 B
GDScript3
|
class_name Spikeball extends Area3D
|
||
|
|
||
|
const BASE_SPIN_SPEED := 120.0
|
||
|
const NORMAL_POWER := 600.0
|
||
|
|
||
|
@export var power: float = NORMAL_POWER
|
||
|
|
||
|
@onready var mesh := $'Mesh' as MeshInstance3D
|
||
|
|
||
|
func _ready() -> void:
|
||
|
body_entered.connect(propel)
|
||
|
mesh.set_instance_shader_parameter(&'hue_shift', power - NORMAL_POWER)
|
||
|
|
||
|
func propel(body: PhysicsBody3D) -> void:
|
||
|
if body is Runner:
|
||
|
(body as Runner).knockback(global_position, power)
|
||
|
|
||
|
func _process(delta: float) -> void:
|
||
|
global_rotation_degrees += (
|
||
|
Vector3.UP*BASE_SPIN_SPEED*power*delta/NORMAL_POWER
|
||
|
)
|