- Home /
controller.collisionFlags & CollisionFlags.Sides Not working
If I use "if(controller.collisionFlags & CollisionFlags.Sides)" it gives me the error: "Cannot implicitly convert type UnityEngine.CollisionFlags' to
bool'", but if I use "if(controller.collisionFlags == CollisionFlags.Sides)" it works fine. But that's not what I want, because I want it to detect it whether it is touching the ground also.
Thanks @courtlandj, that works! Can't upvote yet but if you're having that problem, that is the answer!
Answer by courtlandj · Jun 25, 2012 at 09:07 PM
I am guessing that you're using C#, in which case, to do a bitwise operation on a bitmask, like collisionFlags are, you'd use:
if ((controller.collisionFlags & CollisionFlags.Sides) != 0)
As in this thread
Answer by homer_3 · Feb 24, 2012 at 03:46 AM
You're using bitwise and. Use &&.
It's actually meant to be bitwise in this case, just missing the != 0.
Your answer
Follow this Question
Related Questions
Character controllers using collision detection 1 Answer
Rigidbody and Collision Conflict in FPS game 0 Answers
RigidBody FPS Walker Collision Glitch 1 Answer
Make Character Controller a Box? 2 Answers