Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Creating objects that hover in the air for VR?

Discussion in 'VR' started by CR4CK3RW0LF, Jan 3, 2021.

  1. CR4CK3RW0LF

    CR4CK3RW0LF

    Joined:
    Dec 29, 2020
    Posts:
    2
    Hello there! I'll start by mentioning that I'm still fairly new to unity and I might be asking a pretty basic question.

    So my idea is to have 3 choices hovering in front of the player, suspended and floating in a sort of oscillating fashion that the player can reach out and grab. example of effect I'm looking for in the image below:



    I think the thing that I might be confused about is how to implement something that hovers until the player grabs it, then the item behaves with normal gravity (dropping on the ground, rolling on the floor, etc.) and also doesn't float in the players hand while they hold it.

    i should also mention that I'm using the oculus integration kit to create the players XR rig as shown here:



    and here is the object I'd like to make hover.

     
  2. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    783
    Hi,

    Have you tried the check box IsKinematic, and uncheck UseGravity, to make the object float?
     
    chaitanya222 likes this.
  3. CR4CK3RW0LF

    CR4CK3RW0LF

    Joined:
    Dec 29, 2020
    Posts:
    2
    well so would you be able to reactivate those fields after the object has been grabbed and stop the object from animating?
     
  4. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    783
    Sure, you can do it with a script.
    Rigidbody.isKinematic = false;
    Rigidbody.useGravity = true;

    There are a lot of tutorials for it.
     
    CR4CK3RW0LF likes this.