Raycast to intercept models between camera and target

Hi all,

I’m trying to create a script that use raycast to intercept models between camera and target. I’m going to use this system for a 3° person camera on our project. As stated in other post I it is very difficult to find complete script examples.

Thanks for the help
Luca

1 Like

@Luca_Garattoni Hi Luca, I made a mockup of a raycasting within screen boundries. I’ve also added comments into the code to explain what the code does; It’s a bit disorganized since I did not have much time. Hopefully it will help, if you have any questions I’ll be happy to help!

The good thing about this one is its very adabtable, increasing and decreasing size as well as being able to change the distance during gameplay. However if you dont need these options I’d recommend adding a invisible trapzoid to the camera and scaling it to your preffered size, then use the same technique I use to detect collisions and you’ll have a very similar though much simpeler detection system.

1 Like

@Luca_Garattoni I made the simplified version I described at the end of my last comment aswell; Probably should have just started with this one, but was kind of curious on making an actual raycast version, but the simplified version is way better for coSpaces since it’s significantly less preformance heavy. Hope to have helped you with this!

This is a public remix of an unlisted demo from the CoSpaces Dev team, all about RayCasting, which might be useful:

Thanks all guys. I will focus on your example. Thanks alot!!