Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 rxx1 · Feb 12, 2021 at 02:32 PM · instantiateplayerinvisible-object

Instantiated object is not visible in game

NOTE: ignore black box, its for testing

Initial player: alt text

Instantiated player: alt text using UnityEngine;

 public class DeathCheck : MonoBehaviour
 {
     public GameObject paintBall;
     public GameObject expEffect;    
     public AudioSource splatSound;
     public Transform shotPoint;
     public Transform spawnPoint;
     public float ExpDeviation;
     public float cooldown;
     float cooldownTime;
 
     private void Start()
     {        
         gameObject.name = "Player";
         cooldownTime = Time.time + cooldown;
     }
     // Update is called once per frame
     void Update()
     {
         Debug.Log("Time: " + Time.time);
         Debug.Log("CooldownTime: " + cooldownTime);
 
         if (Time.time > cooldownTime)
         {
             if (Input.GetButton("Fire1"))            
                 Death();            
         }        
         
     }
 
     void OnCollisionEnter2D(Collision2D collision)
     {
         if (Time.time > cooldownTime)
         {
             if (collision.gameObject.tag == "Deadly")
                 Death();
         }
     }
 
     void Death()
     {        
         Respawn();
         Destroy(gameObject);
         Debug.Log("Boom!");
         splatSound.Play();
 
         //Creates 20 balls with random rotations
         for (int i = 0; i < 20; i++)
         {
             float dev = Random.Range(-ExpDeviation/2, ExpDeviation/2);
             float rotZ = i * 18 + dev;
             transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
             Instantiate(paintBall, shotPoint.position, transform.rotation);
         }
 
         //Explotion Effect
         Instantiate(expEffect, shotPoint.position, transform.rotation);
         
                
     }
     
     void Respawn()
     {
         GameObject newPlayer = Instantiate(gameObject, spawnPoint.position, Quaternion.identity);        
     }
 }


screenshot-2021-02-12-162802.png (79.2 kB)
screenshot-2021-02-12-163006.png (93.4 kB)
Comment
Add comment · Show 1
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 AbandonedCrypt · Feb 12, 2021 at 02:38 PM 0
Share

Where do you call Respawn()? or which instantiated player do you mean?

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by rxx1 · Feb 14, 2021 at 04:47 PM

I found the problem, my spawn point was on a different z position then my player, causing it to become invisible

Comment
Add comment · 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
0

Answer by logicandchaos · Feb 12, 2021 at 04:08 PM

I think the issue is with line 52: transform.rotation = Quaternion.Euler(0f, 0f, rotZ); here you are the transform of your player as a temporary variable. You should make a new transform for that Transform temp; outside the loop to create less garbage.

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 rxx1 · Feb 12, 2021 at 04:52 PM 0
Share

sorry I'm not sure I understand. could you send me an example?

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

160 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 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

Bullet wont collide for the other player (PHOTON+UNITY) 1 Answer

How would I destroy and respawn an object based on player distance? 1 Answer

Backround Loader 1 Answer

How to store a variable of the player 1 Answer

Multiplayer prefab player fall through floor on instantiate 0 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