var Power : float = 50.0; var canwalk = true; var jumpPower =4; var jumpdistance : float = 5.5; var speed : float = 5.0; var other : Transform; var Dodgespeed : float = 20.0; function OnCollisionEnter(collision : Collision){ if(collision.gameObject.tag == "wall"){ canwalk = false; if(Input.GetButtonDown("Jump") && canwalk == false){ rigidbody.AddForce(Vector3(-Power,0,0)); } else{ canwalk = true; } } if(collision.gameObject.tag== "solid"){ // i made tag call wall other.transform = gameObject.transform; //this is an error and doesnt work //an error read Only } } function Update(){ if(Input.GetButtonDown("Jump") && canwalk == true){ if (Mathf.Abs((other.position - transform.position).y) < jumpdistance){ rigidbody.AddForce(Vector3.up*jumpPower); } } if(Input.GetKey("w")){ transform.Translate(Vector3.forward*speed*Time.deltaTime); } if(Input.GetKey("s")){ transform.Translate(-Vector3.forward*speed*Time.deltaTime); } if(Input.GetKey("a")){ transform.Translate(Vector3.left*speed*Time.deltaTime); } if(Input.GetKey("d")){ transform.Translate(Vector3.right*speed*Time.deltaTime); } if(Input.GetKey("a")&& Input.GetButton("Jump")){ rigidbody.AddForce(Vector3(Dodgespeed,0,0)); } } function OnCollisionExit(collisionInfo : Collision) { if(collisionInfo.gameObject == "solid"){ //an error read Only other.transform =""; //an error read Only } }
this is my code The Collision Doesn’t Work And The AddForce Of The Input A+Jump
note:
Please Don’t Say Anything about me i know that iam Beginner