Jump to content

Recommended Posts

Posted

I'm holding a hockey stick, and using llRezObjectWithParams to 'fire' the puck, but i'm having trouble getting my projectile to go in the right direction.

Heres what i'm  currently doing, which works fine, except the puck is being fired, 30 degrees to my left, instead of in the direction i'm facing. ( or perhaps the animation i'm playing makes it look that i'm not looking forwards )

fShootPuck() {
    string puck = llGetInventoryName(INVENTORY_OBJECT,0);
    if ( llGetInventoryType(puck) == INVENTORY_OBJECT ) {

        float 	 vel = llGetTime()*50;
        vector   myPos = llGetPos();
        rotation myRot = llGetRot();
        vector   rezPos = myPos + <1.0, 0.0, 0.25> * myRot;
 
        llRezObjectWithParams( puck, [
            REZ_POS, rezPos, FALSE, TRUE, 
            REZ_ROT, <0.70711, 0.0, 0.0, 0.70711>, TRUE,
            REZ_VEL, <vel,0,0>, TRUE, FALSE,
            REZ_LOCK_AXES, <1,1,1>,
            REZ_FLAGS, 0
            | REZ_FLAG_PHYSICAL
            | REZ_FLAG_DIE_ON_NOENTRY
        ]);

    }
}

Oh, i'm also using llGetTime() to set the velocity
But i'm not sure what i should be adjusting to resolve this issue,
Any advice would be appreciated, thanks

 

Posted (edited)
3 hours ago, Biran Gould said:

( or perhaps the animation i'm playing makes it look that i'm not looking forwards )

Unfortunately, avatars' exact facing direction is partially viewer-side. Maybe see if you're having the same issue while sitting on a pose stand?

Edited by Quistess Alpha
Posted

If you are using a default camera angle (for some people, that is "behind the avatar"), would the direction of rez possibly be interpreted relative to where your camera is "looking"? Instead of relative to the direction your avatar is "facing" due to some possible animation..

(If you are looking where your avatar is looking, but from behind..)

 

Posted

These arguments are suspect

REZ_POS, rezPos, FALSE, TRUE,

The 2nd argument, to which you pass TRUE is whether or not the object should rez at the rezzers root instead of at the specified position. You create rezPos only to not use it.

REZ_VEL, <vel,0,0>, TRUE, FALSE,


On your velocity arguments, you pass TRUE for local velocity, so this should be fine, but I wonder if the 2nd argument to not additionally inherit the rezzers velocity is intended as if you happen to be moving when you hit your puck it won't account for your movement.

 

 

 

 

 

  • Thanks 1
Posted
1 hour ago, Extrude Ragu said:

The 2nd argument, to which you pass TRUE is whether or not the object should rez at the rezzers root instead of at the specified position.

No, that shouldn't mean the rezzer's root, but rather the rezzed object's root, as opposed to the geometric center of that rezzed object—basically the difference between llRezAtRoot() and llRezObject().

  • Like 1
  • Thanks 1
Posted

Caveats from llGetPos:

  • When called from the root of an attachment, returns the wearer's region position. To see the position used, enable Develop>Avatar>Display Agent Target and use the red crosshair. If the avatar is sitting on an object, the red crosshair may be hidden by the white one, in the same position.
  • When called in an attachment's child prim, the position given is again relative to the avatar's root position and rotation, but with the offset from the root prim added. Visually, the reported position will only be correct if the object's root is attached to ATTACH_AVATAR_CENTER, at ZERO_ROTATION and ZERO_VECTOR. Moving the attachment's root or changing the attachment point will not affect the reported position. Avatar animation is invisible to the simulator, so it also does not affect the reported position.

 

And from lGetRot:

  • llGetRot incorrectly reports the avatars rotation when called from the root of an attached object, use llGetLocalRot for root prims, instead
    • llGetRot will return an accurate facing for Avatars seated or in mouselook, but only a rough direction otherwise when called from an attached prim.
    • When called in an attachment's child prim, the reported rotation will only be visually correct if the object's root is attached to ATTACH_AVATAR_CENTER, at ZERO_ROTATION. Moving the attachment's root or changing the attachment point will not affect the reported rotation. Avatar animation is invisible to the simulator, so it also does not affect the reported rotation. Also see Single or Root Prims vs Linked Prims vs Attachments.
Posted (edited)
On 11/13/2024 at 12:42 PM, Biran Gould said:

Heres what i'm  currently doing, which works fine, except the puck is being fired, 30 degrees to my left, instead of in the direction i'm facing. ( or perhaps the animation i'm playing makes it look that i'm not looking forwards )

The script is perfectly accurate, the discrepancy in the puck going the wrong way is not something you can fix when you're aiming outside of mouselook (unless you track camera instead of avatar rotation).

Edited by Wulfie Reanimator
  • Thanks 2
Posted
32 minutes ago, Wulfie Reanimator said:

(unless you track camera instead of avatar rotation).

I feel vindicated!!!!

23 hours ago, Love Zhaoying said:

If you are using a default camera angle (for some people, that is "behind the avatar"), would the direction of rez possibly be interpreted relative to where your camera is "looking"? Instead of relative to the direction your avatar is "facing" due to some possible animation..

(If you are looking where your avatar is looking, but from behind..)

 

 

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...