Help needed - only started today

Hi there people. I am trying to do something that I thought would be fairly basic in Unity, but really struggling to get my head around things.

I have a rough map of 200AD York that I have built in Cinema4D which I need to import into Unity, for the ability to then drop on the press of a key (number 1) another 3D model into place on a point on the map…but I can’t seem to get anything to show at all to even begin with.

Advice right now would be really handy, it’s a work thing, and it needs to be demonstrable by the end of the day

If you’re under that much of a deadline, you’d better spend more words and pictures explaining the problem. Getting something to show should indeed be as simple as dragging your model into the scene and clicking the Play button.

So: show us a screen shot of the Scene and Hierarchy tabs. Show where the Camera is relative to the model. Then show us exactly what happens when you press Play. We’ll start with that, and then deal with getting another model to appear when you press a key.

1 Like

Its actually getting the asset to appear first that I am struggling with…it appears in assets, and when I put it in Hierarchy, nothing shows on screen :confused:

So this is what I see now with some jiggery pokey…but none of the textures are there, and I can’t see it on camera no matter what I seem to do currently

You’re seeing something on the camera; there is a big gray wedge on the right side of the Game tab that wouldn’t be there in an empty scene. So, that will be just a matter of moving your Main Camera around until you have the view you want.

As for the textures, that can indeed be a PITA sometimes, and I don’t use Cinema4D so I can’t speak to that directly. Check the Import settings when you have your model selected in the Project tab; there are options there for what to do with the textures/materials. If everything is set correctly, it should Just Work, but in some cases I’ve seen it fail to hook the materials up to the models, in which case you need to select the material (probably there in your Materials folder), and drag it onto the model manually.

Ok exporting as a fbx file has helped a lot. This basically a 2d map that I now need to drop a 3d model onto, the textures can wait, I just need this as a proof of concept today

1 Like

OK, so now, as I understand it, you want a 3D model to appear when you press a key. Here are the steps.

  • Import the 3D model.

  • Drag it into the scene. Position it as desired and make sure it’s textured too (if that’s important).

  • Create a new script (right-click in the Project tab, do “New C# Script”). Name it AppearOnKey.

  • Double-click AppearOnKey.cs and, when it opens in the editor, change the Update method to the code below.

void Update() {
    if (Input.GetKeyDown(KeyCode.Space)) {
        gameObject.SetActive(true);
    }
}
  • Save, switch back to Unity, and drag this script onto your 3D object.
  • With your 3D object selected, uncheck the checkbox right at the top of the Inspector. This should hide (deactivate) the object.
  • Run. Your 3D object should be invisible until you press the spacebar, and then appear.

You could only enable the renderer within Update, if the script is on the game object.

Otherwise, use an empty game object anywhere in the scene. Place a script that looks something like the code below. Make sure to drag the actual object you want to show into the inspector slot. Like @JoeStrout said, make sure you disable the game object before starting.

public GameObject objectToShow; // drag n drop the real object here in the inspector.

void Update() {
   if(Input.GetKeyDown(KeyCode.Space)) {
       objectToShow.SetActive(true);
    }
 }

Oh yes, good point! The procedure I outlined wouldn’t quite work, because a script on a disabled object does not run the Update method. Thanks @methos5k for pointing this out and providing a solution.

Hopefully we weren’t too late…

1 Like