1 last thing I need working for my Alter Space Shooter

So my assignment especially from my last thread where I have to create a 3d object to get it working.

So I created a hidden panel which was part of a requirement. In order to have it appeared. the 3D object needs to be clicked in order to appear (which technically would destroy you anyways.

Here’s my script for the MineDestroybyContact script.

I cannot figure out what the proper code is for my primary mouse button because I want my mouse to click on the mine which would bring up this hidden GameOver panel.

Kowertz

You have the correct code for primary mouse button, but it’s inside an OnTriggerEnter. The trigger code happens in 1 frame, so it’s unlikely you will click the mouse button at the same time.

You could move the primary button code inside an OnMouseDown() function.

Or, you can use the GetMouseButton code inside the Update() function and fire a Physics.Raycast to see what it hits.

Or, you can use IPointerClickHander from the EventSystem.

Please post code via code tags, screenshots make it hard to read.

To make your 3D GameObject bring up a panel, you don’t actually need any code. These steps will suffice:

  • Add a physics collider to the GameObject
  • Add a PhysicsRaycaser to the main camera
  • Add an EventTrigger to the GameObject
  • In the EventTrigger add a listener to OnClick
  • Under OnClick, drag in the panel you want to appear
  • In the method list, choose GameObject.SetActive
  • Tick the box to call it with the “true” paramater

And you are done, no coding required.

Stardog,

created a new function and pasted it under OnMouseDown() function

if you look at the screenshot i posted, theres the 2nd if statement called if(other.tag == “mine”)

apparently the other is highlighted red.

Any idea how to fix it?