I’m creating an FPS and using the FPSWalker that is provided with Unity. I’m trying to detect collisions on the FPSWalker using OnCollisionEnter but it doesn’t seem to work. I have enemies that shoot balls at the player(FPSWalker) - I want to be able to detect with the balls hit the player. The balls bounce of the player as they should, but aren’t registered in OnCollisionEnter → any idea on how to fix this???
my only thought is the balls bounce off the player before the OnCollisoinEnter can gets called
this is a timestep issue and can be fixed by changing the timestep to about 0.001 to 0,002 in the Edit → project settings → time and can be adjusted in the inspector window but this effects performance dramatically i would recomend raycasting the projectiles to detect a collision.
this is also a problem of mine :evil:
can any one help me with my FPSwalker i fond this script online but i can spin around and look up or down? please help
var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
function FixedUpdate() {
if (!grounded) {
moveDirection.x = Input.GetAxis(“HorizontalAir”)*speed;
moveDirection.z = Input.GetAxis(“VerticalAir”)*speed;
}
// If grounded, zero out y component and allow jumping
else {
moveDirection = Vector3(Input.GetAxis(“Horizontal”)*speed, 0.0, Input.GetAxis(“Vertical”)*speed);
if (Input.GetButton (“Jump”)) {
moveDirection.y = jumpSpeed;
}
}
moveDirection = transform.TransformDirection(moveDirection);
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
grounded = (GetComponent(CharacterController).Move(moveDirection * Time.deltaTime) CollisionFlags.CollidedBelow) != 0;
}
@script RequireComponent(CharacterController)
The first person controller supplied with Unity is a pretty good place to start. You’ll find it in the Standard Assets folder.