Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Slow bullets that move in a straight path?

Johnny Mann
Registered User
Join date: 1 Oct 2005
Posts: 202
07-04-2006 06:52
Hi Im working on a flamethrower script. The bullets im referring to are actually objects that start a Fire particle effect once colliding with object, avatars, or the ground.

I am having a hard time making them both slow and in a straight line.

The objects (bullets) are invisible and meant to slowly shoot from the fame thrower when pressed.

I need to figure out how to make them slowly float in a straight line after firing from the flame thrower.

I am using the generic bullet script and have turnes float to 1.0, but upon firing my gun, the only way I can get them to shoot slowly is by adjusting velocity and bullet speed. Unfortunately, the makes the bullet arc rather than travel in a straight line until it hits an aboved mentioned target.

Can anyone point me in the right direction?

Thanks.
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
Try llSetForce...
07-04-2006 07:37
Try llSetForce...

http://secondlife.com/badgeo/wakka.php?wakka=llSetForce

That applies a constant force so you will have to cancel that at some point when the bullet arrives at its destination.
Johnny Mann
Registered User
Join date: 1 Oct 2005
Posts: 202
07-04-2006 08:35
Nice! So if i want a constant force applied but to fall at a downward angle I suppose I would use a vector just under gravity (9.8)

I suppose in the gun script at this point with llSetForce enabled I would have a small amount of velocity and bullet speed.
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
07-04-2006 08:42
I am not 100% certain how to get that working in your case - you'd have to experiment with it in world to get an idea about how it works. Remember that you can combine the vector (provide values for x and z) to form a single llSetForce call. Perhaps others can chime in if they have more experience.

There is also the matter of energy - llSetForce uses an object's energy which gets replenished over time. My guess is that since you are creating something that is small, moves slowly, and covers a relatively short distance, energy is not likely to be an issue for you.
CrazyMonkey Feaver
Monkey Guy
Join date: 1 Jul 2003
Posts: 201
07-04-2006 14:54
Dont bother with setforce or anything.

The droid.. err I mean function your looking for is: llSetBuoyancy(1.0);
Physical objects will now float weightless, hence move in a straight line.
Unoti Quonset
Registered User
Join date: 21 May 2006
Posts: 10
07-05-2006 11:07
I would implement this using llMoveToTarget(). llMoveToTarget() moves at an uneven speed, slowing down as you approach your target. But you can call it multiple times to get movement at a smooth velocity. The basic idea is to pick a "waypoints" along the path you want to travel, in this case, a straight line. To make the velocity approximately constant, you set a new target for yourself using a timer.

General steps I would use:

1. Create a vector of how much you want to move each frame.
2. Set a timer, let's say for every 1 second.
3. In the timer, call llMoveToTarget() for a position that is the current bullet position plus two times your velocity vector, and tell it to take 2 seconds to get there.

NOTE! Even though you told moveToTarget to take 2 seconds to get to the target, you will be setting a new destination 1 second from now, so we're only using half of this. The reason for that is that we want the bullet to travel at an even velocity, not slow down as it approaches its waypoint.


llMoveToTarget is the way to go for this because it provides the right amount of upward thrust to overcome gravity.

This waypoint/moveToTarget technique is how my pink elephant in the Foo Zoo juggles people. That example moves people in an arc, but the same principle would work for going in a straight line.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
07-05-2006 11:11
From: CrazyMonkey Feaver
Dont bother with setforce or anything.

The droid.. err I mean function your looking for is: llSetBuoyancy(1.0);
Physical objects will now float weightless, hence move in a straight line.

Yes, this is the way to do it, I'd say.