I have been trying to make a script for a pressure plate that will activate a bridge moving up to a certain position. I have the bridge moving correctly now, but the OnCollisionEnter code that my player is supposed to activate when touched is sending an error that says "There is no argument given that corresponds to the required formal parameter 'col' of 'PressureActivate.OnCollisionEnter(Collision)'." After hours of trying to fix it I came to this with the same error:
public class PressureActivate : MonoBehaviour
{
public bool isOpened;
void Start()
{
isOpened = false;
}
void Update()
{
OnCollisionEnter();
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Player")
{
isOpened = true;
}
}
}
My bridge code is this:
public class MoveUpBridge : MonoBehaviour
{
public PressureActivate pA;
public float movementSpeed = 10;
private Vector3 endPosition = new Vector3(0, -1, 53);
void Start()
{
pA.isOpened = false;
}
void Update()
{
if (pA.isOpened == true)
{
if (transform.position != endPosition)
{
transform.position = Vector3.MoveTowards(transform.position, endPosition, movementSpeed * Time.deltaTime);
}
}
}
}
I am pretty new to game making and coding and would lobe the help on this problem.
↧