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 Madswint · May 08, 2014 at 09:58 AM · flyingfloating

How would I go about making objects around player float up into the air?

I'm trying to make it so while the player is charging / holding down shift or so, all rigidbodies around him will ~float up into the air~, as if gravity slowly pulled them up, then they stop at a max height I set.

How would I go about doing such a thing? I've looked into a lot of levitate / floating questions, but none of them seem to help me with this specifically.

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 MSpiteri · May 08, 2014 at 10:52 AM

You can use OverlapSphere. Refer to this: https://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html

With that, you will be able get all the colliders around the player within a certain radius. Then, for each, check that they have a rigidbody and make them levitate (remove their gravity and increase their y-position slowly, etc).

If you need another example on how to use the OverlapSphere, go here:

https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddExplosionForce.html

Comment
Add comment · Show 4 · 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 Madswint · May 08, 2014 at 12:12 PM 0
Share

Oh! I'm trying to mess around with this. I was wondering, if this could be used for skills? I mean, taking the game League of Legends, when you click a spell, the area where it will hit, will be marked by a white raycast (atleast so it seems). If I would want to show the radius from the AddExplosionForce as LoL does, do you have any idea how to do such a thing?

avatar image MSpiteri · May 09, 2014 at 06:30 AM 1
Share

Hello again. Before I go to your question, please note that I gave you this link to the AddExplosionForce example so that you can see how you can use the "OverlapSphere" command and the "foreach" loop. In you case you would NOT apply the explosion force; ins$$anonymous$$d, you would simply increase the y-position of each rigidbody to make them float.

Now, going back to your new question about how to show the radius, if you intend to draw a sphere at the point of impact, then you can simply instantiate a semi-transparent sphere at the point of impact and set its radius (scale) equal to the radius of the explosion.

avatar image Madswint · May 10, 2014 at 12:44 AM 0
Share

I ofcourse did that, the problem I run into is that because the rigid bodies have gravity, they will jump up then fall down and continue like that till the force is back down.

What I'm trying to achieve is like the $$anonymous$$an Of Steel flight scene, when he is about to jump you see dirt and small rocks lift up. That's what I want to achieve, just with objects around you.

Do you have any tips on how to fix this?

So far my script is if you hold shift down, a variable will charge up to thr max value of 5, while its charging the force of pulling objects up id increased aswell. When you let go of shift, everything falls back. I am on phone atm, but if script is needed I can log onto pc. Thanks btw, this one is hurting my head

avatar image MidgardDev · May 10, 2014 at 01:36 AM 0
Share

You can disable a rigidbody's gravity, so you could do that OverlapSphere thingie and then just disable gravity for all colliders inside that OverlapSphere, then set a variable for gradual velocity on the Y axis and once that float variable is at a maximum speed that you want, then just slow down and make it look like it's floating in the air.

I'll write you an example if you want.

avatar image
0

Answer by PvTGreg · May 08, 2014 at 10:50 AM

just off the top of my head but you could add a box collider to the player and set it as trigger and add a script that would look for a tag that is on the objects around the player and when it collides with them it could turn gravity off on the objects(on a rigidbody) and add force upwards causing them to float up

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 Madswint · May 10, 2014 at 12:46 AM 0
Share

Ah, I think that would work, but the objets wouldnt look realistic (gravity rotating them or such). Any way to enchance the "realistism" a bit?

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

24 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

Related Questions

I want a flying / floating Charcter 1 Answer

My enemy keeps floating in mid air and need help raycasting! 0 Answers

Simulating Water not working.. 1 Answer

3rd person 1 Answer

Exclude Objects From FloatingOrigin 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