#Raycast stuff

1 messages · Page 1 of 1 (latest)

whole parcel
#

Is there a way to use a raycast or area2d or any other node to detect other scenes or nodes that are inside it?
I'm trying to make a bullet the player can shoot to kill enemies it hits. The enemies are basically just animatedsprite2d nodes with a point light attached. They don't have a collision shape. Is there a way to detect other nodes/scenes without using a hitbox of some sort, and is there a way to get a reference to the node/scene the raycast hit?

cloud crystal
#

Raycasts and areas are physics constructs, they can't "see" anything that doesn't have a collision shape

whole parcel
#

oh

cloud crystal
#

Why don't you want to use collision shape if you don't mind me asking? Since this is kinda the exact stuff hitboxes are designed for

whole parcel
#

it's just that my character isn't a characterbody2d, so it gives me an error if i use a collision shape on it. Does that matter, or will it work anyway?

#

enemies too

cloud crystal
#

Ah yeah that will matter, why not just change them all into character bodies?

whole parcel
#

should I?

cloud crystal
#

Well they are characters, and you need the physics system for your purposes

#

So it makes sense that they should be

whole parcel
#

i guess

cloud crystal
#

You could use AnimatableBody2D but probably makes more sense to use CharacterBody

whole parcel
#

would I be able to replacce the characterbody2d script with the character script i already have?

cloud crystal
#

It's a node

#

You'd just attach your characer script to the node

#

And change your extends declaration to extends CharacterBody2D

whole parcel
#

ok

#

ill try that

#

It worked immediately 💀