I have a character being able to carry a box around with them, but once they press a button(Eg: Press ‘E’ to drop), I want the object to be put on the floor in front of the character. My problem here, is that if I simply set the object to be a certain CFrame in front of the character, the object will be out of bounds if the player is pushing against a wall. Also, ideally I want the object to be on the ground, not floating above or below the character. What’s the best way to approach this?
Is the object collidable with the character? If you’re using collision groups so that the item collides with the floor and walls but does not collide with characters, I’d suggest to set it at their feet, technically inside of their feet.
If the object is like a football or some sort of collidable obstacle, you could do a raycast at feet height in their LookVector for the distance you intend to place it. If there’s a wall there, do the same to the right side.
If you check all 4 directions, and all of them have obstacles too close, then I’d stick it on the floor and move the character upwards so they’re standing on it. That way if they are somehow in a corner with obstacles around them, you still have an option.
Thank you! I’ll give that a go and get back to you! Can’t work on it at the moment, I will ASAP