First Character and loose hit points

Hi everyone,

I’m new in unity3d and i’m trying to do something to understand.

I did a terrain with mountains and rocks, and I want to move and jump my character (first person) around the world.

So, I want to loose “hit points” (health) when they hit with high velocity.

For example, if I jump and hit a rock or on the ground too distance, I must loose health or die (if the collision is strong!).

I`m use the Standard Prefab First Person Controller, and if I put rigidbody component in it, the controller did´nt work well!

Any suggestions?

tks

the first person controller that comes with unity has alot of bugs when you attach a rigidbody. Here’s a simple script you can use as a move script. just add this script to whatever you want as a character and go to component/camera-control/mouse look and add it and also go to component/physics/character controller and add it.

public var MoveSpeed : float = 50;

public var jumpSpeed : float = 55;

public var MoveDirection : float = 45;

public var grounded : boolean = false;

function Update(){

       if(grounded){

                 MoveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

                 MoveDirection = transform.TransformDirection(MoveDirection);

                 MoveDirection *= MoveSpeed;

       }

       if(Input.GetKeyDown(KeyCode.Space))

        {

                  MoveDirection.y = jumpsSpeed;

         }

}

MoveDirection.y -= Gravity * Time.deltaTime;

var Controller = GetComponent(CharacterController);

var Flags = Controller.Move(MoveDirection * Time.deltaTime);

grounded = (Flags & CollisionFlags.CollidedBelow) !=0;

}

as for hit points per speed you would actually have to adjust the script by adding drag to just about everything so that you would be moving different speeds depending on how long the button is held, released, gravity and adding a top speed for acceleration and gravity. Maybe using something like if force = a certain amount then – hitpoints. sorry i can’t be too helpful on that