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 khave · May 04, 2015 at 05:12 AM · space shooterasteroid

cannot show my hazard in space shooter

hi gays~

I follow the space shooter in unity and have problem now

I finish chapter 11 of space shooter which is explosions and then I cannot show hazard in play mode end of the came controller part

i don't know why......T^T...

gays please help me

I made Asteroid prefab and then deleted of Asteroid game object in hierarchy also my asteroid prefab has 'random rotator' 'mover' 'destroy by contact' scripts and 'rigid body' and 'capsule colander'.

I exactly wrote c# script from tutorial and did not copy 'done' scripts

My game controller object has game controller script and include asteroid prefab ..........

i really do not have any idea, why i cannot show may Asteroid in play move

My space shooter does not have any error and warning

help me..... pleaze

This is my came controller script

using UnityEngine; using System.Collections;

public class GameConroller : MonoBehaviour {

 public GameObject hazard;
 public Vector3 spawnValues;

 void start(){
     SpawnWaves ();
 }

 void SpawnWaves()
 {
     Vector3 spawnPosition = new Vector3 (Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
 
     Quaternion spawnRotation = Quaternion.identity;

     Instantiate (hazard, spawnPosition, spawnRotation);        
     
 }

}

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 maddykarthi · Nov 18, 2016 at 11:57 AM 0
Share

same problem did u got the solution

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Cherno · May 04, 2015 at 08:20 AM

Try

 GameObject newSpawn = Instantiate (hazard, spawnPosition, spawnRotation) as GameObject;
Comment
Add comment · Show 2 · 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 khave · May 06, 2015 at 03:49 PM 0
Share

thanks for your answer I tried yours, but I have error. like this " Assets/Scripts/GameConroller.cs(29,81): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement"

what is that.......?

before use "as Gameobject" I did not have error message and only did not show hazard without any warning and error but after use "as Gameobject" in my code i have error......

please help me ...

avatar image Cherno · May 06, 2015 at 04:33 PM 0
Share

Pardon me, my bad. Of course you need to create an appropriate variable to receive the Instantiate function's return type, which is GameObject. So the line needs to be

 GameObject newSpawn = Instantiate (hazard, spawnPosition, spawnRotation) as GameObject;

I changed my comment above to reflect this.

avatar image
0

Answer by OfficeCyber · May 07, 2015 at 06:18 AM

Did you assigned the prefab in the inspector?

Test your prefab pulling it directly to the scene. Is it ok?

Have you checked the values of the spawn positions?

When in play mode, in the Scene view from a far point, can you see the prefab been instantiated???

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Space Shooter: Asteroids not being destroyed 1 Answer

Want Ships & Bullets to transform relative to Camera. 2 Answers

Javascript Fatal Content Error from Space Shooter tutorial in Chrome web build 1 Answer

why the boundary is not working? 0 Answers

Why showing bugs in sample code of space shooting project 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