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 ItzChris92 · Jun 25, 2018 at 11:49 AM · rigidbodylerplooting

Diablo Style loot explosion

Hi, I have a Loot system that generates random loot and then instantiates it. After it has instantiated I would like it to move up and then away in a Diablo style fashion. I've tried a couple of things but get different problems with each, so I'm after some advice on the best way to implement. I tried to add force but I would rather not have a rigid body on the loot, and this was giving problems when multiple items were dropped simultaneously (items would collide and fly all over the place). I have looked at lerp, but am not quite sure how to use this in a random fashion.

Are there any other alternatives?

Comment
Add comment
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

2 Replies

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

Answer by Thomas-Hawk · Jun 25, 2018 at 12:40 PM

Maybe a foreach?

Foreach loot object, Generate a goal vector inside unit sphere, Construct a new vector to keep whatever axis you like (like maybe you want it to always move a certain distance on the y axis or something)

Interpolate the object from its spawn position to this new constructed position.

If you want them to fly up a little, and then back down to the ground, just first generate a vector to get the new X and Z position, and then find the halfway point between the start position and that new vector, then interpolate first to that vector + Vector.up *(howHigh) , before interpolating to the ground.

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 Bunny83 · Jun 25, 2018 at 12:49 PM

Actually in Diablo 1 and 2 the loot just spawned at it's desired resting position and just did an up and downward motion in place. Things like chests simply spawned the loot items one after another.


However if you actually want to spawn it at the chest and move it outwards you can simply use a simple bezier curve. A quadratic curve would be enough, though a cubic may give you more control over the exit and landing normal. Keep in mind that diablo is a tile based game. When the loot is generated the game searches for an empty tile around the loot tile and just spawn the loot there. Also keep in mind that the whole motion can just be a visualization of the loot drop and not the actual loot flying around. Diablo 1 and 2 (never played d3). were 2d games. The whole 3d isometric look was pure well designed 2d sprites and clever layering.


That means when you want to drop loot around a certain point you would first find as many "drop points" on the ground where the loot should end up as you have items you want to drop. Then just iterate through all items you want to drop and move them along a bezier curve which should start at your chest / mob and ends at the corresponding drop point on the ground. This could be easily done inside a coroutine.


Though if you want a more realistical drop, using rigidbodies shouldn't be that of an issue. In diablo gold always comes in "packs" / item stacks. I don't think there was a loot chest or mob that dropped more than 20 items. Also since loot chests with many items take a while until all items are "dropped", there are only a few items "in air" at the same time. Once an item has found it's resting position you can simply remove the rigidbody.


In the end you are the developer. If you are the game designer as well you should know how you want it to look like. If you use another game as inspiration, just look carefully how it behaves.

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

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

119 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 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

Gameobject is climbing out objects with rigidbody 0 Answers

rigidbody.velocity vs lerp efficiency 0 Answers

Is there a way to smoothly transition between two floats, with it slowing down towards the end 1 Answer

Object Scale Lerp with rigidbody addforce jump duration. 1 Answer

Quaternion.Lerp finishing before "t" parameter hits 1 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