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 /
  • Help Room /
avatar image
0
Question by _Railgun · Sep 08, 2015 at 09:22 AM · spawning problems

Spawning objects with force so it looks like someone is randomly throwing stuff

I would like to be able to spawn objects at a random interval with some force at the start so it looks like someone who is off camera is chucking things into the view. I have no idea how to do this and I couldn't find any good tutorials. If someone could help me with this that would be great!

In case anyone was wondering, I'm making a title screen where random stuff gets randomly thrown on to the floor in front of the camera. If the player stays on the title screen for too long the room will get full of random stuff xD

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 _Railgun · Sep 23, 2015 at 04:22 PM 0
Share

It's been two weeks and still no replies...

Does anyone even browse these forums?

1 Reply

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

Answer by etopsirhc · Sep 23, 2015 at 10:51 PM

their is 2 main ways i see you could do this. 1) create a script that will apply a random force to a prefabs rigidbody as soon as it gets instantiated, then create a script to spawn them in.
2) create a script that spawns a 'dumb' (unscripted) prefab in and applies force to the object from within the spawn script.

either way you will need a prefab of the object with a rigidbody on it and a script to Instantiate the prefab at an interval.

if you use GameObject thrown = Instantiate(prefab) as GameObject; you can then pull the rigidbody up with thrown.GetComponent(); and apply a force to that in the direction you want it to be thrown. as for the timing, setting a timeSinceThrow on update to be += Time.deltaTime you can see how long it's been since you threw an object, and can throw another when it's >= the timeTillNextThrow, witch is set randomly at the end of a throw.

there's of course some more randomizing for diffrent angles and things, but once you get the base down it's not hard to see where the randomness needs to be.

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 _Railgun · Sep 25, 2015 at 12:00 AM 0
Share

Thx m8 now I can make progress lol

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Spawn system that doesn't instantiated enemies on top of player or each other (C#) 2 Answers

Problem with using Unity Spawnsystem (Unet / Multiplayer) 0 Answers

Spawning a primitive object under a empty object in the inspector,putting an object as a child of a empty object in the inspector 0 Answers

Stuck with my First AR game 0 Answers

Spawning a number of enemies while condition is true 0 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