Spell casting system

This is more asking for scripting-guidance rather than solving an issue.

I’d like a system which allows spells to be shot through a wand and when colliding with an object, have cool VFX.

I have already developed a working system but the .Touched is not very accurate, and tends to go through an object before it actually registers a touch. This prevents me from applying the VFX.

I have looked into better Touched alternatives but I have come to no success, so I am now asking for an alternative.

Thanks

1 Like

Use raycasting, helps you detect what the ray hits etc. There are built in functions like you wish for.

How would I use raycast for a projectile? It’s also being moved by a VectorForce

I suggest using raycasting alone, and tracing the wand spell effect particles, or a mesh part throughout the raycast, replacing the VectorForce.

Though I do not have much experience in this area, I’ve only done these things a few times.

Oh, I forgot to mention. The gravity is not completely disabled. It is effected by gravity very slightly by 0.75%. So a raycast may not be possible.

If all goes bad, I could just make it completely antigrav, in that case… how would I be able to use the raycast to be accurate (basically account for the travel time instead of hitting a player sooner than the projectile hits them)

if you want projectiles with drop i’d reccomend fastcast (which includes a drop system so you’d have to scrap some of your code), or you could do a very small raycast inside the hitbox of the projecile every frame

1 Like

I’ll try option two soon and let you know how it goes.

I tried option 1 instead and it works. Thank you!

1 Like

Fastcast works very well. Otherwise, giving client ownership to a projectile and propagating events over the network is good too.

1 Like