Godot Version
4.4.1
Question
How do I implement a hades type dash? I’m working in 3d and want a dash that can go through objects without putting the player within objects. Currently I’m using the code below but it still puts me within objects. Please help
var currentLoc = self.global_position
var currentFacing = $Pivot.rotation
var dash_direction: Vector2 = Vector2(
Input.get_axis("Left", "Right"),
Input.get_axis("Forward", "Backward")
).normalized()
if dash_direction.x != 0:
prevDashDir.x = dash_direction.x
if dash_direction.y != 0:
prevDashDir.y = dash_direction.y
var dash_loc = Vector3(0, 0, 0)
dash_loc.x = dash_direction.x * dashDistance
dash_loc.z = dash_direction.y * dashDistance
dash_loc.y = 0
var dashCollide = ShapeCast3D.new()
dashCollide.shape = CapsuleShape3D.new()
dashCollide.target_position = dash_loc + currentLoc
var closeness = dashCollide.get_closest_collision_safe_fraction()
self.global_position = (dash_loc + currentLoc) * closeness
print(currentLoc)
print((dash_loc + currentLoc) * closeness)