Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

New to scripting here, help needed!

Teap Tomsen
Registered User
Join date: 26 Nov 2007
Posts: 9
07-01-2008 18:21
Okay, so I've got me one of these freebie modifyable bows and I'm trying to customize it to make it my own. The first thing I thought I would do is make the arrows fly straight and go into things, as opposed to going at wacky angles whenever they hit a wall or something.

CODE

integer hit;
rotation arot;
vector apos;

default
{
state_entry()
{
llPassCollisions(TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_PHANTOM, FALSE);
}

collision_start(integer detected)
{
arot = llGetRot();
apos = llGetPos();
llSetStatus(STATUS_PHYSICS, FALSE);
llTriggerSound(llGetInventoryName(INVENTORY_SOUND, hit), .5);
llSetStatus(STATUS_PHANTOM, TRUE);
llListen(0,"", llGetOwner(), "pickup");
llListen(0,"", "", "id");
llSetPos(apos);
llSetRot(arot);
//put score stuff here
}


That's not all of the script, but the rest of it doesn't matter and believe me is not causing the problem.

The problem is it hits the wall and bounces before having physics toggled off and phantom toggled on, resulting in a very strange angle and not the bow looking like it is stuck into the wall.

I figured by making the script get the rotation and position of the object right as it hits the wall and then reassigning that position and rotation at the end of the collision_start event, it would readjust the rotation, however it still gets some 'bounce' in before assigning them to the variables. Even if that DID work, it would be an undesirable effect as it would bounce and then realign itself, instead of smoothly going into the wall. If anyone has any advice or suggestions please reply here or send me a message in-game.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
07-01-2008 20:18
Are you sure it's bouncing?

I'm wondering if the physics engine thinks the arrow is bigger than it looks.

Does http://wiki.secondlife.com/wiki/LlGetBoundingBox return something close to what you think it should?
Teap Tomsen
Registered User
Join date: 26 Nov 2007
Posts: 9
07-03-2008 22:45
If I use the example listed on the wiki for llGetBoundingBox where when I touch it it morphs the target to its bounding box, it gets quite a bit bigger and looks quite weird...

Don't know how to fix this. :(