I must thank you all to begin with for being such a huge help to my game project.
The thing is, I am making my character jump, but I have som gravitation issues. He will only jump when he on the edge of say a hill or something. This idea is great, but with one problem. I use a simple character controller with a modified SimpleMove script on him. But it takes almost ages before he reaches the ground.
Increasing the mass while he is a RigidBody dont really help, and no, I don’t want him to use RigidBody again. Is there a way to increase gravity or something while he uses a Character Controller?
Gravity/Physics doesn’t hav effect on character controller, you hav to write your own gravity code and if you wish to use back the rigidbody instead of character controller, u can make the character fall faster by changing the gravity value in Edit Tabs->Project Setting->Physics there ( increase mass doesn’t make thing fall faster, feather and bowling ball falling at the same speed if in vacuum )
you can make it fall faster by decreasing from it’s position.y coordinate a value * Time.deltaTime. (note: position.y is readonly, so you will have to make smt like position -= new Vector3(0, value * Time.deltaTime, 0); )
Ooooh! That’s right, forgot about it. It makes it more static though, but that is what gravity is right? Unless your under water, was my thought. But if that will ever be the case I could just change it back or manipulate the script once it collides with the water. Thanks anyway!
EDIT: Or if I would ever want the player to fall in different speeds, but others than colliding with water I would never believe it happening, hee hee.
i was speaking earlier about value * Time.deltaTime, well you can make a generic getter/setter for the value variable, let’s say our value it’s actually named fallingSpeed;
so we’ll do something like this:
public class CharMovement : MonoBehaviour{
//some other var declarations and such
private float fallingSpeed;
public float FallingSpeed{
get { return fallingSpeed; }
set { fallingSpeed = value; }
}
//some other methods and such
void Start(){
//some other initializations and such
fallingSpeed = 5.0f; //for example
}
void Update(){
//all your calculations implementations go here (or at least most of them)
//when you need to apply gravity on your object, since it's in air (so you'll have some conditions to set...)
transform.position -= new Vector3(0, fallingSpeed * Time.deltaTime, 0);
//some other calculations and such
}
}
and here’s another part of code:
//in other script, let's say on the script that detects if the player entered the water (we have a script on the water, and the "Player" tag on the player)
void OnTriggerEnter(Collider other)(){
if(other.tag == "Player"){
//player is in the water, so we'll need to decrease the fallingSpeed of CharMovement script
other.GetComponent<CharMovement>().FallingSpeed /= 2;
}
}