My player is a ball, the actual model is a grunge-like unperfect sphere. I managed to move it on the Z axis (as I wanted since it’s a jump n’ run), but it seems the gravity value I entered on the Physics (Project settings) config did not work.
In other words, my player does not “adapt” himself to the terrain and it “flyes” when the terrain goes down.
Also, my terrain is not… Solid? So my ball goes through walls (and floors I guess). Here’s my code so you can laugh at me :razz:
var speed : float = 8.5;
function Update() {
horMovement = Input.GetAxis("Horizontal");
if (horMovement) {
transform.Translate(transform.forward* horMovement * Time.deltaTime * speed);
}
}
I Googled this a lot, including ways to move players but answers are not clear enough, at least for this kind of game. Any ideas?
Thank you for reading and please let me know if I was not clear enough myself.
The reason that the ball is not falling because you don’t make the object to fall. You change the gravity setting but it only affects the object with rigidbody. So, simply assign Rigidbody to the object. Select the object then go to Component - Rigidbody.
Or you can use CharacterController for the player. It’s better than Physics. So check out both and see what’s best for your option. Go to the Unity Documentation about it. You will know all details you need.
A rigidBody and some colliders later, I’ve got the ball to roll. Notice that it rolls for… one second, and it just stacks on the floor. Also, when it rolls, it REALLY rolls, I mean, i’ve got the camera attached to the sphere and here’s how it ends:
My guess: I don’t have any guess, i’m new at this.
I’ve read about the character controller before, and it seems to have its limitations regarding gravity, doesn’t it? I mean, pherhaps it is good for a human, but for a ball?
Thank you for answering!
#Edit
Never mind, got it (at least for now) with rigidbody.MovePosition. Thanks.