in my mario game i want to spawn coin only if i hit bottom of the brick. it spawn coins if i hit from side ways when i jump. how can i control this too?
the easiest way is to just put a box collision component in the exact area you want,
otherwise if using math you have to realize that the actor location is ‘usually’ the center of the mesh. so the center of the character is lower than the center of the brick on sideways too.
you can use bounds to check if the top of the character is lower than the bottom of the brick or just use box collider
thank you sir box collision component worked. I would like to do it with math too
math you have 2 choices,
you can check if the actor is below like you have but it would be
note this is pseudo code
BrickActorZLocation-BrickActorZHalfHeight > ActorLocation+ActorHalfCapsuleHeight
or you can use the DotProduct to compare how closely the hit direction is to the world UP Vector.
very good thank you. i ll give a try