First Person Controller

Hi there folks,

I was just wondering what I need to do in order to use this premade camera (First Person Controller) to actually affect other objects. Let’s clarify this a bit. I want to use this controller to run into things like boxes. These boxes of course need to be pushed or fall once I run into them. Right now they don’t react at all and since I am a non-coder I am not sure what to do :slight_smile: Any help?

Thomas

Edit: fixed the subject.

It seems to be done with a capsule collider usually.

If you want a really simple example, simpler than the full FPS tutorial, look here:

http://unity3d.com/examples

Download the old “Physics Demo”–it contains a scene called “fps playground” that is pretty basic but it has boxes you run into and knock down with physics.

(Also, in “Other Examples” on that page are some other little scenes, including “First Person Movement.”)

Hopefully you’ll find some useful code to start from there.

either of these links might be of help as well:

http://forum.unity3d.com/viewtopic.php?t=1987&highlight=fps+controller
(read joe’s post)

http://unify.bluegillweb.com/scriptwiki/index.php?title=PhysicsFPSWalker

Flamin heck!
I just typed up a full detailed how to and my computer crashed…

The short version is this:

go New scene add a plane(to walk on) a cube(to push)
and a fps controller prefab

add a collider to each,(mesh collider to plane, box collider to cube-these may appear by default)

add a rigidbody to the cube
And you should be away…

Let us know how you get on.

Fear not the scriptlords-they sleep better when they’ve fed their minions lots of helpful little scripts…

Thank you you know who you are

AC :twisted:

Thanks for your answers guys. I still can’t get it to work properly. It seems like I get random results with it. The first person controller has two child objects (Graphics and main camera). I need to add a collider to the “Graphics” and the “parent”? I just tried it by only adding these components to the “Graphics” object but that didn’t work. I then placed a colider and rigidbody to the “parent” object and then it works (well not always). I must be doing something wrong. Maybe I am not understanding it fully here.

Thomas

i don’t know much about the fps tut and this is all iirc but

I need to add a collider to the “Graphics” and the “parent”?
no. add a rigidbody to the cube you want to push. iirc the fps controller doesn’t use a rigidbody or collider at all.

if you look at the hierarchy of the fps tut it’s parented as

first person controller

graphics
main camera

weapons

none have colliders or rigidbodies attached. it uses a character controller instead which i think basically has the equivalent of a capsule type collider built in (not sure exactly). height and radius will affect it’s size. if you need more accurate collision (ie pushing the box with a hand) you’ll need to build it differently. maybe by attaching a physics rig (game empties with colliders attached) to a ragdoll or your animated model. you can still use the walker script but you’ll need to write your “push” script. hth

or you could start from scratch. Add Cube, capsule, plane. put the camera right at the top of capsule, and parent by dragging the camera onto the capsule in the hieracy window.Add a rigidbody to both capsule and cube, add the fps walker script to the capsule, and try dragging the mouselook(look in project window, in camera scripts)script from the project window onto either the camera or the capsule.

Try not to add too much other stuff as sometimes the bits and pieces can sort of contradict each other
AC
Hey Pete what does hth mean?

Here is an fps walker that pushes rigidbodies.

To use it, find the FPS walker in:
“Standard Assets/Scripts/FPSWalker.js”

and replace the script with the one attached to the post.

You also have to assign a rigidbody to all objects that you want to be pushable.

15490–514–$fpswalker_694.js (1.56 KB)

hth = hope this helps