I am making my first game with pretty awesome Unity.
I want to have my ball character controls like that in “Iron Wars” game for android.
It’s like the ball faces the direction of the joystick direction and moves forward by rotating in that direction. I have success in getting the input from virtual joystick.
But when using force and velocity the ball moves in that direction but its face doesn’t have any particular direction. I want to use physics for other tasks also so can’t fake this by transform only.
Also how to get that kind of top down camera view constantly facing the ball in middle of the screen.
Help is much appreciated.
Hi
For the camera you can try to use the SmoothFollow
camera script from the standard assets and modify the damping values.
Have you tried to use the character controller?
If you are using a sphere with a rigidbody I would rotate the sphere to the target. In what way do you think will this affect your other physics?
How do you set the direction/point the ball should look at? Some kind of auto aim?
If you provide more detail its easier to help you.
Edit:
OK
the ball character in the game you mentioned is made out of multiple objects, the “base ball” that is rotating and some kind of body/face.
I guess you want to apply force to have the rotationg effect. I suggest you try to handle it using a charactercontroller or better create your own controller script and a wheel collider.
Your hierarchy should look like this
Character (ControlScript and RigidBody)
- Sphere (SphereCollider)
- WheelCollider (Empty GO with WheelCollider)
then you can extend your character as you like.
In the controlScript you need to reference the wheelcollider and make it moving using wheelColliderVar.motorTorque = joystickInput
(calculated with speed things and so on)
You are also able to rotate the whole char using joystick input and lookAt scripts.
Hope this is helpful