Jump to content

Hover over object Script


DJay Skydancer
 Share

You are about to reply to a thread that has been inactive for 610 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

First, apologies if this is in the wrong place. I know nothing about scripting, but I'm looking for a script that will enable my avatar to hover over an object when I 'add' it. For example, I create a box, add the script and when I add it to my avatar I will hover above it. Hope this explains when I mean well enough. Does this exist?

Thank you in Advance.

DJay

Link to comment
Share on other sites

Yes, there are several ways to accomplish this. llSetHoverHeight will force a physical object to hover at the specified static altitude. The linked page even has an example script you can use and tinker with that largely does what you want from the start. Alternatively, llGroundRepel can be used to make the object hover a set distance above the current terrain (and optionally water) level directly below. Both functions work when in attachments and will apply the hover to the wearing avatar.

And for future reference, every forum now has a pinned posting guideline post which gives guidance on acceptable content. To summarize the one for this forum:

  • If you're looking to try writing the script yourself and need advice, this is the place to post.
  • If you're looking for something that already exists, ask in the Wanted forum.
  • If you're looking to hire someone to write the script for you, ask in the Inworld Employment forum.

 

  • Like 1
Link to comment
Share on other sites

I'm guessing you want to wear the object as an attachment. If this is so you should attach it to something like AvatarCenter and adjust its position so it's where you want it below your feet.

Then you should adjust your avatar's hover height so that the attached object shows above the ground where you want it. Unfortunately the scripting language doesn't offer a means of changing an avatar's hover height (at least as far as I know). RLV does, though, so if you're using a viewer that supports it you can script the change in hover height.

If the object is something you want to rez on the ground and then stand on, then you can use a sit script that sets a sit target sufficiently high and plays the standing animation of your choice.

And if you want to be able to move around, this happens in my first scenario. Otherwise you can make the object a vehicle on which you sit (again setting the sit target and animation as required), and whose movement you can control using the arrow keys.

  • Like 1
Link to comment
Share on other sites

I guess I misunderstood your intent. What are you trying to achieve here? Provide more context and examples.

Because when I read the initial post, my understanding was that you wanted an attachment that causes the avatar to float in the air when worn. The bit about the avatar appearing to float above the attachment seemed like a cosmetic visual that I assumed you would achieve by positioning the attachment appropriately (i.e., below your feet).

Is this meant to be some kind of animation override? Like, you could have the attachment play a high priority animation that makes your avatar appear to be higher off the ground than normal and fake the effect of it "hovering" over the attachment by positioning it below your feet.

I should point out that when you "add" and object, you are basically wearing it like a hat on your avatar (depending on which attachment point you choose). Since this object is being worn, it moves relative to the avatar and its attachment point - not the other way around. So you have to manually position the attachment to the desired location on your avatar.

If you want the avatar to be moved relative to the object, then making it a vehicle as KT suggests might be a better approach...

  • Like 1
Link to comment
Share on other sites

Thank you for your replies Kingsley and Fenix - I'll try to explain further.

I've made a box. The prim in the photograph I attached earlier is the root prim. When 'added' I stand inside the box but I want my feet higher. I want to share this with others so rezzing it on the ground is not practical. I want the box to be 'Add' and for the avatar to be at the right height for it.

Adjusting my hover height before adding the box isn't really an option because I would have to get others to do that too.

The point is that once the box is added, I'll be able to use my dance hud to dance inside it without my feet sticking out of the bottom of it. It's rather like the Barbie box that's been going around clubs for years now - you just add it and carry on dancing as you were before you added it.

Sorry for delay in replying ... I'm in Ireland.

Screenshot 2022-09-29 at 05.57.09.png

Edited by DJay Skydancer
Forget to add image
Link to comment
Share on other sites

1 hour ago, DJay Skydancer said:

Thank you for your replies Kingsley and Fenix - I'll try to explain further.

I've made a box. The prim in the photograph I attached earlier is the root prim. When 'added' I stand inside the box but I want my feet higher. I want to share this with others so rezzing it on the ground is not practical. I want the box to be 'Add' and for the avatar to be at the right height for it.

Adjusting my hover height before adding the box isn't really an option because I would have to get others to do that too.

The point is that once the box is added, I'll be able to use my dance hud to dance inside it without my feet sticking out of the bottom of it. It's rather like the Barbie box that's been going around clubs for years now - you just add it and carry on dancing as you were before you added it.

Sorry for delay in replying ... I'm in Ireland.

We don't have access to the data/functions you'd need to be able for this to work 100% hands-free (I wanted to say feet-free.).

  • Like 1
Link to comment
Share on other sites

Ok, so this is meant to be  a dance platform wearable for no-rez areas.

Like Lucia says, we don't have any functions that can modify an avatar's body hover height property by script.

But you may be able to achieve the desired effect to some degree using the initial example I referred to and llSetHoverHeight. Here are my thoughts on what it would entail:

  1. Attach the dance box/platform to "Avatar Center" and position it with the base below your feet. This is a special attachment point that is linked to the agent's global position/rotation and doesn't move with any body parts. It will be static no matter what animations are playing. Also, attachments remember the point and position they were last attached to, so once you attach it to the avatar center and position it as desired, it will always go there even if you select "add" next time.
  2. Use the llSetHoverHeight example script to make the avatar "hover" up from their current position. The example on the wiki adds 5 meters, but you can experiment to see what looks right. Make it such that the base of your dance box attachment looks to be close the the ground when the avatar is hovering.
  3. When an avatar is made to hover this way, it will pay the falling animation. You can override that with a dance animation that has a priority of 3 or higher.
  4. Also when in this "hovering" state you are essentially falling - which means if you get bumped or move, you will continue to slowly slide around without stopping. You can counteract this by explicitly setting your velocity to zero. Edit: or by pressing the Space key: that will stop you in place (and cause you to levitate down a little, but the hover of the script will pop you back up once you release the key).

Below is a bare-bones proof of concept:

//DEMO

integer toggle = FALSE;
float offset = 0.4;     //height above current pos to hover

default
{
    state_entry()
    {
        llStopHover();
    }

    touch_start(integer total_number)
    {
        if(toggle = !toggle)
        {   //turn on
            vector sPos = llGetPos();
            llSetHoverHeight(sPos.z - llGround(ZERO_VECTOR) + offset, FALSE, 0.1);
            llSetTimerEvent(3.0);
        }
        else
        {   //turn off
            llStopHover();
            llSetTimerEvent(0.0);
        }
    }
    
    timer()
    {
         llSetVelocity( ZERO_VECTOR, FALSE );   //counteract any bumps or moves
    }
}

 

Edit: and a picture of the attachment in action. A high priority dance animation is playing over the falling animation. I suppose you could get fancy and actually use llSetAnimationOverride to change the falling down animation to a dance while the attachment is worn (and then clear the override upon detaching the object).

Note I've modified the base size to be stretched to meet my feet and the ground. Other users may need to fine tune these positions for the first time.

image.png.c89c6d9fa3ae360cf15295976c8f7ad3.png

Edited by Fenix Eldritch
additioinal info
  • Like 1
Link to comment
Share on other sites

7 hours ago, DJay Skydancer said:

but when he passed the box to me and I added it the box was then underground

That's how it starts out, you have to click it to activate. Remember, this is mostly an illusion... the platform is being made to look like it's sitting on the floor with your avatar on top of that. But in reality, the platform is a carefully positioned attachment that only looks right when the avatar is lifted up slightly to pull the whole thing together.

It's also important that this thing always restart when used because it needs to get the most up to date position of the avatar before it tries to set the hover. If it uses an old position, you might get some very unexpected results. For example, suppose you are at a club at 500 meters in the air and use thing thing. The hover height it will use will be 500.4 meters. Now let's say you remove it without turning it off and go to another club at ground level, let's say 25 meters in elevation. If you put the dance platform back on now without resetting it, it will still retain the previous calculated height of 500.4 and will attempt to hover you to that altitude.

I didn't provide a full solution, only a basic example that you could expand on. If you want this to be as automated as possible, I suppose you could have the activation and deactivation happen on an attach event, rather than a touch_start.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 610 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...