- Home /
iOS game: Physics with ConstantForce
I am currently making my first game to iOS and i need some advices about physics. This is my game.
You need to reach the center with the ball by moving iOS device using gravity. But in reality, maze itself do not move. Force is added directly to the ball, while maze it static.
I wrote a simple script that works. I like the effect and how it works.
GetComponent<ConstantForce>().force = new Vector3 ( speed * Input.GetAxis ("Mouse X"), 0f, speed * Input.GetAxis ("Mouse Y"));
But i have few problems. The ball should roll in passage when player turn fast the ios device in other/opposite direction, when the ball is rolling near passage, and the ball should roll into. But it doesn't. Maybe i should changes materials? Currently the ball is set to "steel", while ground/walls are "ice". Or should i use rigidbody.addforce, or translate instead?
Ball mass is 0.3 to 1, works fine. If i set more mass, it starts to become slower changing direction.
Physics are the core element of my game so please give me some advice :) I will provide more information if needed
Personally i think the problem is that device isn't fast enough to instantly count sudden direction changes and to apply it at the right time. How to fix it?
Hii.. I would like to give some advice on this :
You should use acceleration to move ball and based on acceleration value change x and y position value by translating ball.
Answer by tebandesade · May 13, 2015 at 06:24 PM
If your using physics, always write code in the fixedUpdate function, and as you're using Physics, stay with addforce because force is a physics element