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 KyrenD2 · May 21, 2018 at 02:32 PM · strange ioc

Spawning fireballs at a certain point,Spawning Fireballs at a certain location

I am making a game that I need to spawn fireballs at a certain point and I have no idea how to do it. Here is the code for the spawn.

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class FireballSpawn : MonoBehaviour { public float minSpawnDelay = 1f; public float maxSpawnDelay = 3f; public GameObject fireballPrefab;

 void Start()
 {
     Spawn();
 }

 void Spawn()
 {
     Vector3 spawnPos = transform.position + new Vector3(Random.Range(6, -6), 5, 5);
     Instantiate(fireballPrefab, spawnPos, Quaternion.identity);

     Invoke("Spawn", Random.Range(minSpawnDelay, maxSpawnDelay));
 }

}

,I am making a game and I need to spawn fireballs at a certain point and have no idea how to do it.Here is the code for the spawn.

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class FireballSpawn : MonoBehaviour { public float minSpawnDelay = 1f; public float maxSpawnDelay = 3f; public GameObject fireballPrefab;

 void Start()
 {
     Spawn();
 }

 void Spawn()
 {
     Vector3 spawnPos = transform.position + new Vector3(Random.Range(6, -6), 5, 5);
     Instantiate(fireballPrefab, spawnPos, Quaternion.identity);

     Invoke("Spawn", Random.Range(minSpawnDelay, maxSpawnDelay));
 }

}

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 MT369MT · May 21, 2018 at 02:44 PM 0
Share

Hi, I don't understand what you want to do. I tried this script and it works fine. It spawns fireballs in a random range of points and every random amount of time. Isn't it what you wanted?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KjipGamer · May 21, 2018 at 02:58 PM

When you mean at a certain point, do you mean in range of the player, at a random location in the world or at a predetermined location?

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 KyrenD2 · May 21, 2018 at 03:01 PM 0
Share

What I mean is i have platforms for the player to jump on and there are openings for the fireballs to go through to try and hit the player. I need the fireballs to spawn in that one opening. This is also a 2D project.

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

83 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

Related Questions

Why I can't buy a 47,50$ assets with my 50$ card 0 Answers

Driving simulator reaction time data collection in response to trigger events 0 Answers

WaitForSeconds doesn't work in Coroutine. 3 Answers

UnityObjectToClipPos: o matching function, when develop in Linux Unity 0 Answers

I need help.I made a house in a blender and i transfered it into unity.But in unity that house is glitching and my character can pass trough that house. 1 Answer


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