Hi!
I’m trying to make the simplest platformer prototype with the simplest physics (falling with gravity, moving left and right, and (maybe) jump). For example:
void Move () {
if (!isDying || !isDead || !isShooting || !isFalling)
{
float amountToMove = Time.deltaTime * Input.GetAxis("Horizontal") * playerSpeed;
transform.Translate(Vector3.right * amountToMove);
}
}
void ApplyGravity() {
float amountToMove = Time.deltaTime * gravity;
transform.Translate(Vector3.down * amountToMove);
}
The problem is i don’t know how to make collisions without physics and with isKinematic enabled. The only thing i know is to use a OnTriggerEnter function, so added a isTrigger to all objects and wrote (Hero.cs):
void OnTriggerEnter (Collider otherGameObjectCollider) {
if (otherGameObjectCollider.gameObject.tag == "ground") {
Debug.Log("ground/wall collision");
}
}
I know that i need stop my hero to prevent falling (walking) through the ground but i really can’t think it out.
Sorry for the dumb question.