hi
how can i stop an object(static mesh attach to player) to not go through walls or floor
any help would be highly appreciated,
thanks
hi
how can i stop an object(static mesh attach to player) to not go through walls or floor
The picked up obj needs to be an actor. It’ll need collision components w/overlaps enabled encasing it. one for each side.
e.g. thin box collision on the bottom that extends 1cm below the obj.
When the collision overlaps (static, dynamic etc etc) other objects you disable movement on the controlling actor for said direction.
e.g. our bottom collision component overlaps the floor. So we disable downward movement.
Simplest approach ^^^
An alternative would be to use the mesh collision to generate hit results. The hit results will give a normal which you can use to determine the direction of impact. This will allow you to disable movement.
There’s also the continuous trace approach. In which you fire a trace for each side on tick or timer. Take the hit result (if blocking) and get the length of the trace for start to hit location. If it is less than or equal to N, disable movement input for direction.
e.g. If moving left and the left trace returns a hit with a distance of 5cm you disable left movement input.
@Rev0verDrive thank you for the suggestion that seems like it will work just one question can you show how can i disable character controller(hands) movement in z axis
If you are using Character Movement Component you simply use conditional checks on input. Whether to allow (process it) or not (disregard).
For example if using mouse pitch to control the up/down movement of the object.
On obj overlap/block of bottom collision set bPitchDownDisabled? to true.
For the input handling something like the following will work.
Axis Inputs (Forward/Right, Mouse) fire every frame, so you always want to send something. If disabled you send 0, just as if you didn’t move the mouse.
@Rev0verDrive great thank you so much , it worked for pc version , and i need to do the same for VR version , can you give some light on that please , how can i disable the movement of controller in z axis .