Answer the question
In order to leave comments, you need to log in
Why doesn't contact work in unity?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Transform : MonoBehaviour
{
public float groundCheck = 1f;
// Start is called before the first frame update
void Start()
{
transform.position = new Vector3(0,0,0);
}
void onCollisionEnter2D(Collision2D other){
if(other.gameObject.tag == "Finish"){
groundCheck = 0f;
print("afafa");
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.D)){
transform.position += new Vector3(0.1f, 0, 0);
}
if(Input.GetKey(KeyCode.A)){
transform.position -= new Vector3(0.1f, 0, 0);
}
if(Input.GetKey(KeyCode.W)){
if(groundCheck == 0){
transform.position += new Vector3(0, 1, 0);
groundCheck = 1f;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question