View Single Post
Thread: C# for Unity
Originally Posted by Oracle View Post
Just pointing out the limitations of what you've chosen. Any implementation needs to be tested at the edges. Of course what you've chosen will work to jump off anything, but that's also a potential problem. All the raycast will check is distance until collision with an object. Specifying what kind of objects prevents bugs like jumping off game objects that are untouchable for the player, but still detected by the raycast, since raycast looks for all objects with colliders by default.

The reason I bring up the layer is because I know raycast can result in some weird interactions if you aren't careful. Using just:

if (physics.raycast(position, down, MAX_DIST))
Grounded = 1;

as how you decide if you can jump leaves room for possible errors if the raycast hits, say, a bullet object that has a collider. Fixing that would be as simple as assigning all bullet game objects to a "hazard" layer or something and specifying the raycast should ignore "hazard" layer objects. raycast has that feature already implemented.

Hey! Thanks for that. That'll come in handy sometime. I didn't really think about that.

Anybody got any projects they wanna share? Once I am a little bit further into the development of this, I'll be sharing mine a bit.