- Home /
zombies and the player SUDDENLY(not a beginning but a middle of playing) falling down
I'm developping a zombie game with networks. I was just killing zombies in the game, but suddenly zombies and the player start falling down through the terrain.
And when I was standing on a box, it happens again~ suddenly my character was falling down. It seems like physics does not work anymore.
I'm using unity steer, and angry behave for AI. Give me a hands plz~
ps: Thank you for your replying Bunny83
- It is a 'normal' network game~
- And I was just playing my self(just me), I saw that happening in my PC.
- And Yes, when I was standing on a box suddenly falling down.
- And the zombie and the player does not has a rigidbody.
- And unity steer use a CharacterController.
Here is my zombie's source.
And the player's source is, I use BootCamp's soldier's script.
void Update() { if (!networkView.isMine) return;
if (energy < 0)
return;
if (behaviorTree != null &&
behaviorTree.Tick(this, null) != BehaveResult.Running)
behaviorTree.Reset(this, null);
Vector3 dir;
if (zombiAni.IsFiring)
{
dir = new Vector3(finder.TargetDirection.x, 0, finder.TargetDirection.z);
if (dir != Vector3.zero)
transform.rotation = Quaternion.LookRotation(-dir);
}
else
{
dir = new Vector3(moveDirection.x, 0, moveDirection.z);
if (Speed <= 0.1f)
dir = new Vector3(finder.TargetDirection.x, 0, finder.TargetDirection.z);
if (dir != Vector3.zero)
transform.rotation = Quaternion.LookRotation(dir);
if (zombiAni.IsWalking ||
zombiAni.IsRunning)
{
UpdateDirection();
UpdateMovement(false);
RegenerateLocalSpace(moveDirection);
}
else
UpdateMovement(true);
if (dir != Vector3.zero)
transform.rotation = Quaternion.LookRotation(-dir);
}
}
private void UpdateDirection() { if (!finder.IsTargetFounded) return;
if (MaxForce == 0 || MaxSpeed == 0 || Time.deltaTime == 0)
return;
Profiler.BeginSample("Calculating forces");
Vector3 force = Vector3.zero;
foreach (Steering steering in Steerings)
{
if (steering.enabled)
force += steering.WeighedForce;
}
Profiler.EndSample();
Vector3 clippedForce = Vector3.ClampMagnitude(force, MaxForce);
Vector3 newAcceleration = (clippedForce / Mass);
if (newAcceleration.sqrMagnitude == 0 && !HasInertia)
{
Speed = 0;
}
Vector3 newVelocity = Velocity;
smoothedAcceleration = OpenSteerUtility.blendIntoAccumulator(0.4f,
newAcceleration,
smoothedAcceleration);
newVelocity += smoothedAcceleration * Time.deltaTime;
newVelocity = Vector3.ClampMagnitude(newVelocity, MaxSpeed);
Speed = newVelocity.magnitude;
moveDirection = newVelocity;
}
private void UpdateMovement(bool isUpdateGravityOnly) { //Apply gravity if (isGrounded) upSpeed = 0; else upSpeed -= gravity * Time.deltaTime;
Vector3 movement = new Vector3(0, upSpeed, 0);
if (!isUpdateGravityOnly)
movement += (moveDirection * Time.deltaTime);
//Move controller
CharacterController controller = GetComponent<CharacterController>();
CollisionFlags flags = controller.Move(movement);
isGrounded = (flags & CollisionFlags.CollidedBelow) != 0;
}
Some code? Use edit
! So it's a network game then a bit more detailed description would be great. How owns the playerobject? aka do you use an authoritative server setup or the "normal" one? Where do you see you're falling through something? On another client or on your own pc? Does it happen when you don't move? do you use any forces that are applied to your player? Some debugging info: Do the zombies/player still have a collider? I never used unity steer... does it use a CharacterController or a Rigidbody?
Well, everything looks right to me not to say even perfect ;) Can't find a reason for such behaviour in that script. As long as you do not remove colliders by script (or changing them to isTrigger) it should work. Did I get that right, you are the server and play alone (like single player)? Do you use any special network code? NetworkViews that monitor the transform bypass the CharacterController.$$anonymous$$ove when they get updated. But if you're the owner of the NetworkViewID you shouldn't get any updates since you're sending them.
Yes I was playing as server and alone.. and even if I disable networkview components of the zombie and the player. It is still happening lol.. :'(
Answer by Drakulix · Apr 03, 2011 at 12:42 PM
how come i can't use the soldier script when i make a new scene in the bootcamp project
Your answer
Follow this Question
Related Questions
Falling through the floor issue 11 Answers
Items falling through floor? 2 Answers
Falling Through My Elevator.. 3 Answers
Falling through world. 1 Answer
Terrain edit problem 1 Answer