First Person and Lifting

Hey all,

I’m starting a project where you play in first person. My first question is how to implement that- I tried using the First Person that came with Unity, but I’m unable to look right at left. Secondly, I want to be able to lift other objects so that they hover in front of me and I can walk around with them- Portal style. I’m new to unity and C# and I would really appreciate the help!

Thanks!

Unity suggest a Component based architecture.
So, if you’re going to use the default First Person Controller, I would suggest to develop a GrabObject component that you put on the same game object and that communicate with it.

You also need a Pickable component that you add to game objects that can be picked up.
The pickable object could also simply use an object tag “pickable” and you can put all mechanic in the GrabObject component.

The component will need to :

  1. Find objects in the field of view, or center of the screen. You can use Physics.Raycast and the object tags for this.
  2. Use some Input to trigger the pick-up
  3. Then you can reposition the object and parent it to your 1st Person Controller using its Transform
  4. You can then use some other Input to drop the object, and then use RayCast again to put it back in the world where you stand. The object will need a Collider and RigidBody if you want it to fall down.

This should be enough to get you started.
Good luck!