- Home /
count how much force is applied
In my sample game there is 1 wall and 4 players. The player is moving on x axis and z axis. Wall has a Box Collider and Rigidbody and set the Mass = 4. Player also has a Box Collider and Rigidbody and set the Mass = 1.
When I move the player to the wall the unity physics engine apply the force to the wall and a wall move slightly towards the force direction. When 2 Players simultaneously force the wall move its position accordingly and so fourth.
What I want is I want the output in debug console how many players are applying a force to the wall.
for example: If the one player is applying the force to the wall then output should be Player =1; if the two player is applying the force to the wall then output should be Player =2; if the three player is applying the force to the wall then output should be Player =3; if the four player is applying the force to the wall then output should be Player =4;
Here is my MoveScript and a Screenshot of my Setup:
MoveScript
using UnityEngine;
using System.Collections;
public class MoveScript : MonoBehaviour {
public float speed = 2.0f;
void Update () {
Vector3 move = new Vector3 (Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
transform.position = transform.position + move * speed * Time.deltaTime;
}
}
here is a screen shot of my setup
Your answer
Follow this Question
Related Questions
Collider question 0 Answers
OnCollisionEnter Push Object Problem 0 Answers
Particle collision with a rigidbody. Adding explosive force? 1 Answer
The force on a collider which is penetrating the other collider 1 Answer
Reuse a collision 0 Answers