Home > database >  best way to interact with objects in Unity 3D
best way to interact with objects in Unity 3D

Time:09-17

I am a beginner in Unity and not really familiar with lots of things and currently making a game for our project. I searched a lot on how to interact with objects but they all have different way to do it so I can't understand what is the best way to implement interactions in the scene.

What I want to do is like when my character come to a table with a newspaper in it, there will be bubble pop up to that says "view" or "read" then 2D assets will pop-up to read the content of the newspaper. What is the best way or maybe the easiest way to do these events?

The game I am creating is a 3d Isometric Perspective game if this helps.

CodePudding user response:

  1. Add GameObject around the table.
  • Add box collider to the GameObject.
  • set false to isTrigger option.
  • This Collision can handle event when the character comes to around the table.
  1. Create Script and add to the GameObject.
GameObject popup;

private void OnTriggerEnter(Collider other)
{
  if(other.tag == "character") {
      popup.SetActive(true);
  }
}

void OnTriggerExit(Collider other)
{
  if(other.tag == "character") {
      popup.SetActive(false);
  }
}
  • Related