How to Shape Casting?
Asked Answered
C

2

0

I need help with shape casting, I search in the documentation and I found nothing 😢. Does anyone knows how to shape casting?

Crumhorn answered 26/2 at 1:13 Comment(0)
H
0

https://docs.godotengine.org/en/stable/classes/class_shapecast3d.html

Set shape, mask, body/area collision to what you need.

var shape_cast : ShapeCast3D

func create_shape_cast():
	shape_cast = ShapeCast3D.new()
	shape_cast.shape = SphereShape3D.new()
	shape_cast.collide_with_areas = true
	shape_cast.collide_with_bodies = true
	shape_cast.collision_mask = 8
	add_child(shape_cast)
	
func use_shape_cast(origin : Vector3, target_pos : Vector3 = Vector3(0,-1,0)):
	if !shape_cast:
		create_shape_cast()
		
	shape_cast.global_position = origin
	shape_cast.target_position = target_pos
	# Check within the same physics update
	shape_cast.force_shapecast_update()
	if shape_cast.is_colliding():
		print("colliding")
Hubbub answered 26/2 at 18:19 Comment(0)
C
0

Hubbub thank you so much mate 🥹

Crumhorn answered 26/2 at 18:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.