Search code examples
c#androidunity-game-enginegame-physicsgoogle-cardboard

addforce in unity android


I´m coding a game for google cardboard in unity for android. At the same time I have a controller in the PC that tracks hand movements and send UDP messages to the game to move the player accordingly.

In the game the main character is parented by a rigidbody and when I receive the commands I apply a force over it using rigidBody.AddForce()

I debuged the force being applied and the values are correct but the main character does not move.

If I run in in local Unity it works as expected, the message is received, the force calculated and applied and the character moves.

But when I load the game in the phone the message arrives, the force is correctly calculated but the character (and therefore the camera) does not move at all

Any clue what can be happening there?


Solution

  • The problem was the rate at witch the force is being applied.

    In the PC the Update() function get's called very fast and therefore the AddForce is called constantly piling up a good amount of force.

    In the Phone, the FPS are fewer and the Update function is called less often, then the force added is piling up more slowly.