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
-1
Question by brickboy700 · May 28, 2014 at 12:56 AM · error

Robots Won't Spawn With Script

I'm making a shooter and I'm working on a Navigation AI for an enemy. Here's the script for it (JavaScript).

 var target : Transform;
 
     function Update()
     {
         GetComponent(NavMeshAgent).destination = target.position;
     }

However, when i added this script to the enemy, the enemy spawning script won't cooperate with the script. Here is that script (C#).edit This is the spawning script

     using UnityEngine;
 using System.Collections;
 
 public class RobotSpawner : MonoBehaviour 
 {
     public GameObject robot;
     public int respawnTime = 3;
     public Vector3 spawnValues;
     public int robotCount;
 
 
     void Start ()
     {
         StartCoroutine (SpawnWaves());
     }
 
     IEnumerator SpawnWaves ()
     {
         while(robotCount < 0)
         {
         
             Vector3 spawnPosition = new Vector3 (Random.Range(-spawnValues.x,spawnValues.x), spawnValues.y, spawnValues.z);
             Quaternion spawnRotation = Quaternion.identity;
             Instantiate (robot, spawnPosition, spawnRotation);
             yield return new WaitForSeconds (respawnTime);
     
         }
     }
 
 }

This is really frustrating so I would l would really like help, ask any question.

Comment
Add comment · Show 2
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 rutter · May 28, 2014 at 12:57 AM 0
Share

What specifically isn't working? What's happening that shouldn't be, or isn't happening that should be? All you've shown us is a script that sets a destination and a script that rotates and moves... the two don't seem to reference each other in any discernible way.

avatar image brickboy700 · May 28, 2014 at 10:13 AM 0
Share

just edited the post for the spawning script. I've tried to save the robot as prefab, but the transform that allows it to charge at the player won't work. I have to save the robot into the scene. However when i do that, when the main robot is destroyed, the spawned robots stop spawning.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Sabre Pilot · May 28, 2014 at 11:50 AM

AIs are extremely hard to create I don't blame you for having a problem. I have a suggestion. Copy and paste that into JS Evaluator, if it is JavaScript, it should detect any fault you have in the JavaScript and alert you once it has been checked for errors. If it is Script, I can't help you out, I want to, but I don't know Script at all. Mac Download App(Mac Descargar): JS Evaluator Mac

Windows Download(Ventanas JavaScript Evaluador):JS Evaluator Windows

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 brickboy700 · May 29, 2014 at 10:55 AM 0
Share

I do appreciate the help, but the reason I posted this was because the prefab won't save transforms I put in to it. Therefor I had to keep the main robot in the scene, but when the main one is destroyed the others stop spawning. Do you know much about prefabs?

avatar image
0

Answer by brickboy700 · Jun 18, 2014 at 02:06 AM

I've rewrote the script and the problem is with the prefab spawning. I recommend for future developers to finish your prefabs before saving them as such.

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 Kiwasi · Jun 18, 2014 at 02:07 AM 0
Share

I'm puzzled as to why you make this recommendation. Its perfectly fine to change a prefab and hit apply to change the master prefab.

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Animation spins wildly after completed 0 Answers

BCE0049 error with network script 0 Answers

Cannot implicitly convert type `float' to `int'. An explicit conversion exists (are you missing a cast?) 2 Answers

NullReferenceException problem 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