Hay…
i new comer. i have question i try a cube move headed for boxCollider but not something happen and debug not come out to consol, then among two of them have Rigidbody. Thanks in advance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Jalan : MonoBehaviour
{
int speed = 4;
public bool noSpeed;
Rigidbody cubeRB;
// Start is called before the first frame update
void Start()
{
cubeRB = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
if( noSpeed == false)
{
MoveCube();
}
}
void OnTriggerEnter(Collider other)
{
if ((other.gameObject.CompareTag("BOXCOLLERD")) && noSpeed == true)
{
Debug.Log("Hiit");
cubeRB.transform.position += Vector3.zero;
}
}
void MoveCube()
{
cubeRB.transform.position += Vector3.right * speed * Time.deltaTime;
}
}