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 AGC · Mar 15, 2015 at 04:00 PM · spawnspeedsmoothincreasematching

How to match the speed of objects and the spawn speed of objects?

HELP HELP HELP! Hello Unity Community. I'm new to Unity and to C#.I want to create a game for my practicing and i am stuck with a problem.

i want that the objects spawn and smoothly it increase the speed of spawning. and it the same time it increase the the movement speed of objects. and it don't find the gap in the middle and don't go inside of each other.

no problem if the code is in java Script.

just like DON'T TAP THE WHITE TILES game

`This is the code that i'm using for spawn the objects.`

 using UnityEngine;
 using System.Collections;
 
 public class Spawner : MonoBehaviour 
     public float spawnWait = 0f;
     public float startWait = 0f;

   public GameObject[] spawnObjects;
 
 
     // Use this for initialization
     void Start ()
     {
         
     }
 
     
     IEnumerator SpawnWaves()
     {
         while (true)
         {
             {
                  //Instantiate a random enemy.
                 int enemyIndex = Random.Range(0, spawnObjects.Length);
                 Instantiate(spawnObjects[enemyIndex], transform.position, Quaternion.identity);
                 yield return new WaitForSeconds (spawnWait);
         
             }
         }
     }
     void Update ()
     {
         if(spawnWait > 0)
         {
             spawnWait = spawnWait - 0.0001f;
         }
     }
 }

This is the code that i'm using for the speed of objects using UnityEngine; using System.Collections;

public class Force : MonoBehaviour {

 public float currentSpeed = 0.0f;
 public float maxSpeed = 10.0f;
 public float increaseValueOfSpeed =0.0f;


 // Use this for initialization
 void Start () 
 {
 }

 

 void Update ()
 {
     transform.position+=(Vector3.down *Time.deltaTime*currentSpeed);


     if(currentSpeed<maxSpeed )
     {
         currentSpeed+=increaseValueOfSpeed*Time.deltaTime;
             
     }
 }

}

thanks in advance for your help!!!!! alt text

tiles.png (29.7 kB)
Comment
Add comment · Show 5
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 siaran · Mar 15, 2015 at 05:03 PM 0
Share

You write 'no problem if the code is in java Script.'

Does that mean you know how to do it in javascript but not in c#? If so, why not convert your javascript code to c#? If you get stuck somewhere, just post the part you don't know how to convert.

If that's not it, it's not very clear what your problem is exactly. You don't know how to do something in c#? What do you want to do? Or some c# code is not acting as you expect? What is your code, what do you expect it to do, and what does it actually do?

avatar image AGC · Mar 17, 2015 at 08:17 AM 0
Share

Thanks for quick reply no i don't know how to write JavaScript. I mean by no problem if the code is in JavaScript that i can convert JavaScript to C# (just if someone know the answer in JavaScript so that's why). And i am expecting from code to increase the speed of spawning and the speed of object moving down so that they don't find gap in the middle of each other and they don't go inside of each other.

i mean is soon the spawn speed go higher the object movement speed should go higher is well so there speed match with each others.

once again thanks for your reply.

avatar image POiD · Mar 17, 2015 at 11:40 AM 0
Share

So as you spawn new objects, do you want the speed of only those new objects to be faster than the previous objects or do you want the speed of all previously spawned objects to be sped up too?

 OBJ #     Spawn Time     Speed of Object
 1           0             1
 2           10            2
 3           18            3
 4           24            4
 
 **OR**
 
 OBJ #      Spawn Time     Speed at 0   at 10   at 18   at 24
 1            0                1    ->  2   ->   3   ->   4
 2            10                        2   ->   3   ->   4
 3            18                                 3   ->   4 
 4            24                                          4

avatar image hexagonius · Mar 17, 2015 at 12:26 PM 0
Share

Save a reference to the last spawned item and measure its distance to where it spawned. If that's greater than it's height spawn the next one and move it where the distance to the former piece is exactly the height (without changing the spawn point of course). With this you can increase falling speed without problems and you would get the tiles without gaps.

avatar image AGC · Mar 17, 2015 at 10:05 PM 0
Share

Hi hexagonius thanks for your quick reply. can you please show me the code which code i can use for increasing the speed and spawning so that they don't find gap each others i mean by increasing speed that it increase the speed in the gameplay when it reach to specific time or score and then increase the speed and keep that speed. and is well the spawn time also match with the speed of objects falling..

Thanks..

0 Replies

· Add your reply
  • Sort: 

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

Fast moving object jitter. RK4 integration 1 Answer

Problem : Change speed animation when run it not smooth 1 Answer

Object Creation Speed incease 2 Answers

Increase time for rigidbody game objects? 1 Answer

Make an object increase speed when entering trigger 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