So I’m making a game. Most of the time, when I use magic, I just find the player’s mouse position and make the attack go there. However, this time, I’m making it so that other players can use magic barriers to block attacks. How can I make it so that the magic moves detonates early when hitting a barrier or a obstacle that wasn’t in the way before? Maybe constant raycasting or just going in a DIRECTION until it hits something?
Also, if it helps, the “barrier” is a part that wraps around the player if they activate it. It’s cancollide is set to false.
The shield has a set durability. It absorbs the damage taken, but if the damage taken is greater than its durability, it just subtracts the amount of damage by its durability. The shield also has a model. So I want it to explode when it hits the model (Non collidable), not when it hits the player. (There is a sizable gap between player and shield). Any ways to detect non collidable objects?
You could make the magic a projectile which is attracted towards a line force (mouse.Hit) and the projectile has a hitbox around it. When it hits the barrier/shield you could run the durability function. Also a cool way to break parts is to build them from smaller pieces and weld them all together the use :BreakJoints on the model to shatter it.