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 ashi200 · Apr 02, 2014 at 09:40 AM · gameobjectrandomspeedrandom.range

I want gameobjects to move randomly on screen without overlapping.`

i have several gameobjects on which i have applied some texture.I want them to move randomly on screen without overlapping with each other i.e they should never collide and should acquire random positions on screen every time.

Comment
Add comment · Show 7
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 senc01a · Apr 02, 2014 at 09:50 AM 0
Share

How about adding a behaviour that moves randomly which can also detect collisions and react accordingly?

avatar image ashi200 · Apr 03, 2014 at 11:40 AM 0
Share

and how can i do that ? any scripting refrences ?

avatar image Hoeloe · Apr 03, 2014 at 01:46 PM 1
Share

How about looking at some of the basic features Unity offers? Like collisions. Those are one of the fundamental things Unity provides. Also, your objects will have a velocity vector, which will be defined at random, so if you want them to "go back in opposite directions" when they hit each other, then it's clearly just a case of detecting a collision and inverting the velocity (times the whole thing by -1). Seriously, this is really simple, and you could have easily solved this if you'd bothered doing any research first.

avatar image ashi200 · Apr 03, 2014 at 05:07 PM 0
Share

@Hoeloe : I did a lot of research before co$$anonymous$$g up with this question but i guess you didn't understood my question correctly that resulted in such absurd comment of yours.

avatar image koray1396 · Apr 03, 2014 at 05:34 PM 0
Share

I'm sorry but Hoeloe has a point.

Simply, create a script and attach it to all objects. I assume you have boundaries on screen, so when these objects hit each other or hit walls, they will go in opposite directions. Also I assume your game is 2d. in this script, you create a random vector and random speed. and these objects will move in this speed and direction vector. I don't know what kind of objects you have, let's say they are circles, then you should just implement a collision logic. you can do this in many ways, if you want this to happen as they are billiard balls, it would be a geometry problem, to find which direction each would go.

if you can explain what kind of objects you have and how they will react to collisions, you can get better help.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Key_Less · Apr 03, 2014 at 05:20 PM

I would suggest researching flocking algorithms. It will allow your objects to have decently random movements while avoiding collisions with each other. You can find some JS and C# script references here. But before jumping into the code, I'd recommend investigating how flocking is intended to work so you can have a better understanding of it's capabilities and uses.

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
avatar image
0

Answer by HariKrishnan · Apr 02, 2014 at 10:03 AM

can you use waypoint concepts. to apply for each gameobject.

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 ashi200 · Apr 02, 2014 at 11:52 AM 0
Share

That would be good but not random.And that would be too tedious.

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

25 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

Related Questions

Random Speed to an Object Rotation 0 Answers

Generating a Displacement Map in Unity3d? 1 Answer

I don't understand the random number generator output. 1 Answer

How to Send a GameObject Flying in a Random Direction but With Always the Same Velocity? 1 Answer

destroy gameobject when collider is fast enough? 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