Question by
bbautocustoms · Jul 15, 2021 at 12:05 AM ·
triggershow
Show/hide specific object only when player is in specific collider(trigger)
Hi, I tried few examples but nothing works ... I don´t know so much about scripts so maybe my fault
I need to show and hide some gameobjects with colliders when key is pressed ...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class showhide2 : MonoBehaviour
{
private void Update()
{
if (Input.GetKeyDown(KeyCode.X))
{
GetComponent<Renderer>().enabled = !GetComponent<Renderer>().enabled;
GetComponent<BoxCollider>().enabled = !GetComponent<BoxCollider>().enabled;
}
}
}
This is working for me, but is it possible to have a colliders around this objects and show/hide specific object only when player is in specified trigger?
For example when i´m in trigger around my trailer and press x i can show/hide loading ramps ... My players object is changing 3rd person controller/car controller using enter exit vehicle ...
I tried different examples from internet with entertrigger actions but not worked for me :(
Please help. Thanks a lot.
Comment