Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by shaaafeee · Oct 15, 2018 at 11:17 AM · 2d gamepixel art

Game Object visible in Scene mode but not visible in Game mode.

Right after I applied Object pooling for the obstacles and made the obstacles to a Prefab it's no longer showing in Game mode but it's visible in Scene mode.
Any help would be appreciated.

capture.png (84.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Legend_Bacon · Oct 15, 2018 at 01:37 PM

Hello there,


My first guess is that they get instantiated behind the background. Once instantiated, try selecting them in the scene and change their Z values.


Another cause could be Layers. If you've grouped your enemies/obstacles under a specific layer, make sure your camera is rendering them (Camera -> Culling Mask).


Other than that, I think you could try giving a little more info if you want more answers. Like your instantiation/pooling code, your setup in the scene hierarchy, etc...



I hope that helps!

Cheers,

~LegendBacon

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shaaafeee · Oct 16, 2018 at 11:30 AM 0
Share

I tried checking those. $$anonymous$$y initial prefab's z value is 200. And the prefab is clearly visible in game mode but when I Instantiate it it's not visible. And according to the ordering layer, obstacles and character are assigned to foreground making it visible. I can share the code if you'd like.

avatar image Legend_Bacon shaaafeee · Oct 16, 2018 at 11:38 AM 0
Share

Please do, then we can make sure nothing's wrong there.

On another note, do they really have a Z value of 200? This sounds silly, but since all I see here is 2D, could it be that the obstacles actually spawn behind the camera (out of its frustum) ?

avatar image shaaafeee Legend_Bacon · Oct 16, 2018 at 11:44 AM 0
Share
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  public class ObstaclePool : $$anonymous$$onoBehaviour {
  public int hurdlePoolSize = 5;
  public float spawnRate = 4f;
  public GameObject columnPrefab;
  public float column$$anonymous$$in = -1f;
  public float column$$anonymous$$ax = 3.5f;
  private GameObject[] hurdle;
  private Vector2 hurdlePoolPosition = new Vector2(0, 0);
  private float timeSinceLastSpawned;
  public float spawnXPosition = 20f
  private int currentColumn = 0;
      void Start () {
      hurdle = new GameObject[hurdlePoolSize];
      for (int i = 0; i < hurdlePoolSize; i++)
      {
          hurdle[i] = (GameObject)Instantiate(columnPrefab, hurdlePoolPosition,Quaternion.identity);
      }
  }
  void Update () {
      timeSinceLastSpawned += Time.deltaTime; 
      if (GameController.instance.gameOver == false && timeSinceLastSpawned >= spawnRate)
      {
          timeSinceLastSpawned = 0;
          float spawnYPosition = Random.Range(column$$anonymous$$in, 0);
          hurdle[currentColumn].transform.position = new Vector2 (spawnXPosition,spawnYPosition);
          currentColumn++;
          
          if(currentColumn >= hurdlePoolSize)
          {
              currentColumn = 0;
          }
           }
    }
  }
avatar image
0

Answer by shaaafeee · Oct 16, 2018 at 12:49 PM

I found the solution. I played with the z axis, set the position to zero therefore it's working now. Thanks for the help . It was a silly mistake.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Legend_Bacon · Oct 16, 2018 at 02:29 PM 0
Share

Ah, I did think that a Z of 200 was a little weird for a 2D game.

Glad I could help!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

106 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Making a 2D 16-bit game. 0 Answers

Help with 2D topdown combat 1 Answer

When should I use tilemap and game object? 1 Answer

2D Top down physics with ground (slippery floor...) 1 Answer

Problem With Pixel Art Pixel Size 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges