Grabbing system idea

Consideration about how to implement the grabbing system:

  1. We can use either a raycast, probably casted from the default pawn camera, or we can detect a collision with a trigger volume.
  2. If we use the recast solution raycast we could look at collision presets and objects, see if something here is good for us or if we need to create something new. If we use trigger volume solution it will be enough to add a component to the every object we can grab.
  3. PROs & CONs: probably the trigger volume component will be easier to implement, but it will be more difficult to handle the object manipulation, instead with raycast it should be more challenging at first but easier and more flexible in future. Raycast could be overkill for this game.

Question answers

  1. I think a component will give us more performance and flexibility than inheritance
  2. You can find what to grab just by looking at the absence of the component
  3. I know what to grab by raycast and look at the object type. Let’s see where the course goes! :smiley:
  4. I would work with a chair at the moment, then with a table, so it will be very useful to have a component or an object type that will let us understand what it is grabbable.
1 Like

I agree that using the raycast system is the best approach. However, finding the right property to look for is an outright pain in the Unreal docs!!

APlayerCameraManager maintains a “view target” which is the primary actor the camera is associated with. So in this sense, the “target” is actually more like the “owner.” I wish they’d call it a “parent” or some other term, because then the AController class (another that inherits AActor) also has a GetViewTarget() function:
AActor * | GetViewTarget() | Get the actor the controller is looking at

I’m thinking that this sounds like the right function to use. I would have a hot key which when pressed would activate a grab component of the chair. That component would get the chair’s transform relative to the pawn’s transform, and then maintain that same “parent-constraint” (as they call it in Maya) until the user releases the chair. This could cause some noisy movement, though, as the chair would have to update its position as an offset from the pawn’s position at every tick. Depending when the frame was rendered, the chair could lag a bit and look rather bad.
-Scott

Just throwing another idea that doesn’t use Raycast…
So I thought about using a component of “trigger volume” around the Pawn - perhaps in a shape of sphere - which detects collision with specific type of objects (the logic is quite simple, i get a list/array of objects colliding with this sphere and i look for a specific object type among them).
In this case I would look for “SM_Chair” type.

Arrr… I’ve never used Raycast in Unreal, but if it be similar to Unity’s raycast, I may be able to get this to work. If I couldn’t use Raycast, perhaps vagnerland’s idea of sphere volume could work. A collider could be setup around the default player and ye could check if they overlapp as well as if a key be pressed (For grabbing).

1 Like

Privacy & Terms