Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Collision Ball

GuanPeng Woodrunner
Registered User
Join date: 12 Jul 2009
Posts: 11
08-18-2009 01:53
Hi, I have some problem with my code. A few balls are created within a container, and the balls will collide and bounce away from each other. Can someone enlighten and help me with this? Thanks.

CODE
integer sec;   
default {
state_entry ()
{
// Make sure that Physical is turned on
llSetStatus (0, TRUE);
}

collision_start (integer total_number)
{
do
{
// Set a vector
vector dist;

// Force the x,y,z coordinate up
dist.x = 1;
dist.y = 2;
dist.z = 1;

// Scale the vector to a fixed length
vector changed_vector = llVecNorm(dist)*1.5;

// Apply the changed vector to the particle
llApplyImpulse(changed_vector, FALSE);
llSetForce( < 1,1,1 > , TRUE);
}

while(sec == 1);
// Set the vector
vector dist;

// Force the x,y,z coordinate up
dist.x = 1;
dist.y = -2;
dist.z = 2;

// Scale the vector to a fixed length
vector changed_vector = llVecNorm(dist)*1.5;

// Apply the changed vector to the particle
llApplyImpulse(changed_vector, FALSE);
//llSetForce( < 3,3,3 > , TRUE);

}

collision_end (integer total_number)
{
do
{
// Set the vector
vector dist;

// Force the x,y,z coordinates up
dist.x = 1;
dist.y = 2;
dist.z = 1;

// Scale the vector to a fixed length
vector changed_vector = llVecNorm(dist)*1.5;

// Apply the changed vector to the particle
llApplyImpulse(changed_vector, FALSE);
//llSetForce( < 3,3,3 > , TRUE);
}

while(sec == 1);
// Set the vector
vector dist;

// Force the x,y,z coordinate up
dist.x = 1;
dist.y = -3;
dist.z = -2;

// Scale the vector to a fixed length
vector changed_vector = llVecNorm(dist)*1.5;

// Apply the changed vector to the particle
llApplyImpulse(changed_vector, FALSE);
//llSetForce( < 3,3,3 > , TRUE);

}
}
shootjutsu Absent
Registered User
Join date: 28 Oct 2009
Posts: 15
12-08-2009 20:34
I have similar question like this!
Can anybody help? :/
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-08-2009 21:11
if the problem is that the balls shoot out of their container you can try applying less force or see my solution in the other thread (it's a building technique more than a scripting technique)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
shootjutsu Absent
Registered User
Join date: 28 Oct 2009
Posts: 15
12-08-2009 21:15
From: Void Singer
if the problem is that the balls shoot out of their container you can try applying less force or see my solution in the other thread (it's a building technique more than a scripting technique)


Hi there, thanks for your kind reply.
For the applying less force, I have done it before, but it still slowly floats out of the box.
May I know your solution in another thread, where is it?
Thank you very much!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-08-2009 21:35
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
shootjutsu Absent
Registered User
Join date: 28 Oct 2009
Posts: 15
12-09-2009 01:26
From: Void Singer


I'm sorry but isn't that the same thread as this current one?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-09-2009 01:38
they were so similar i copied the wrong one
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -