My rough design of the grabbing system

The grabbing system is made up of two components – detecting the graband actually doing the grab.

For detecting the grab, the idea is to cast a ray every frame along the direction to which the player is facing. (This ray stuff is just an abstraction, we can attach an invisible thin rectangular tragger volume as the ray) Then for the chair object, create a new C++ actor component called “GetGrabbed”. In the function TickComponent in “GetGrabbed.cpp”, check every frame that if the ray collides with the chair. (Use function IsOverlappingActor() to check) When that condition is true, we allow the play to press some key to trigger the grab action.

For taking the grab action, we can just set the coordinate of the chair some distance in front of the player’s pawn in every frame, which creates an illusion that the chair is being grabbed by the player. When the player releases the chair, we just fix the chair’s x and y coordinates and make the chair snap to the floor.

Privacy & Terms