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 nanahs · Feb 19, 2014 at 04:54 PM · rigidbodyvelocitypooling

mass spawning rigid bodies but only some keep the given velocity

So I have spent way longer than I would have liked on this and I still can't figure it out.

I am spawning anywhere between 1-50 simple enemy units that have a rigid body and in Start() I assign a velocity to them. Only some of the rigid bodies retain the velocity that I give them when the game is running. Roughly seems like 1/3rd of them lose the velocity. I would appreciate it if someone could shed some light unto this issue.

It is possible to solve this issue by checking in Update() but I feel like that is just redundant at this point and shouldn't be needed if I am doing this properly.

 using UnityEngine;
 using System.Collections;
 
 public class Enemy : MonoBehaviour {
 
     public float speed = 5f;
     public Vector2 travelDir;
 
     void Start(){
 
         assignVelocity();
     }
 
     void Update(){
         
         Debug.Log(rigidbody2D.velocity);
         
     }
 
     private void assignVelocity(){
 
         travelDir = Random.insideUnitCircle;
         rigidbody2D.velocity = Vector2.one;
         rigidbody2D.AddForce(travelSpeed*speed);
     
     }
 }
Comment
Add comment · Show 3
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 Ed unity · Feb 19, 2014 at 11:47 PM 0
Share

Are the created objects effected by gravity? That would cause objects to shift their velocity. Also if any of the rigidbodies have drag, the velocity will decrease over time.

Are you noticing a sudden drop in velocity or does the velocity of the objects decrease over time?

avatar image nanahs · Feb 20, 2014 at 06:25 PM 0
Share

Sorry I should have clarified a bit more. I have gravity turned off, all drag is set to zero. The issue is that only some of the objects actually have their velocity changed from the Start() method. It seemed like it wasn't being run every time. Can this happen? If so why would it happen?

avatar image mattyman174 · Feb 20, 2014 at 09:53 PM 0
Share

Are you spawning them all in the same spot? If they are in close enough proximity to touch eachother they could be reacting to collisions and removing their initial velocity.

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

20 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

Related Questions

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

How to simulate AddForce? 1 Answer

Velocity and Time.scaleTime 2 Answers

What is the velocity on a given axis of a rigidbody? 2 Answers

How to make an object moving in a certain direction, move in specific steps like 0.1f 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