Simple movement question/"bug"
I'm in a problem with a simple movement script, my object is too slow when walking, and when I press to jump it becomes faster, so if I stop pressing to jump it becomes slow again. Could it be a friction physics sistem by the RigidBody? That's the script that I used:
public class movement : MonoBehaviour
{
public Rigidbody rigid;
public float puloForca = 50f;
private bool podePular;
public float velo = 200f;
public float rot = 200f;
void Start()
{
}
private void OnCollisionStay(Collision collision)
{
podePular = collision.contacts[0].point.y<transform.position.y;
}
private void OnCollisionExit(Collision collision)
{
podePular = false;
}
void Update()
{
if (Input.GetKey("w"))
{
rigid.AddForce(transform.forward * velo);
}
if (Input.GetKeyDown("space") && podePular == true)
{
rigid.AddForce(transform.up * puloForca);
}
}
}
("puloForca" means like Jump Force and "podePular" means like Could Jump) (Sorry for my bad english too) If anyone could help I would be very grateful
Can you transcribe this:
podePular = collision.contacts[0].point.y<transform.position.y
It's like x = a < b :)
This line indicates that podePular is true in these conditions, that's what I saw in a video
The script now worked, I reduced the mass of the object and solved the problem, but anyways thanks for the help (and again, sorry for my bad english)
Thanks!