Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
FootBall Football  

Football

Here's a small script for a football. The ball can be kicked by just walking against it. Touching it causes the ball to bounce up in the air a couple of feet. You can also talk to it by saying "kick" which causes the ball to move with a certain vector strength and direction. "High kick" makes the ball going forward up in the air.

Category: FootBall
By : Niklas Waller
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Football
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Football_1.lsl
1
2 default {
3 state_entry () {
4 llListen(0, "", "","");
5 // Make sure that Physical is turned on
7 }
8
9 collision_start (integer total_number) {
10 // Get the vector that points from the kicker to the ball
11 vector diff = llGetPos() - llDetectedPos(0);
12
13 // Force the z coordinate up
14 diff.z = .1;
15
16 // Scale the vector to a fixed length
17 vector kick_vector = llVecNorm(diff)*5;
18
19 // Apply the kick vector to the ball
20 llApplyImpulse(kick_vector, FALSE);
21 }
22
23 listen (integer channel, string name, key id, string message) {
24 if(message == "kick") {
25 // Get the vector that points from the kicker to the ball
26 vector diff = llGetPos() - llDetectedPos(0);
27
28 // Force the z coordinate up
29 diff.z = .1;
30
31 // Scale the vector to a fixed length
32 vector kick_vector = llVecNorm(diff)*10;
33
34 // Apply the kick vector to the ball
35 llApplyImpulse(kick_vector, FALSE);
36 }
37 else if(message == "high kick") {
38 // Get the vector that points from the kicker to the ball
39 vector diff = llGetPos() - llDetectedPos(0);
40
41 // Set the z-coordinate high up
42 diff.z =500;
43
44 // Scale the vector to a fixed length
45 vector kick_vector = llVecNorm(diff)*25;
46
47 // Apply the kick vector to the ball
48 llApplyImpulse(kick_vector, FALSE);
49 }
50 }
51
52 touch_start (integer total_number) {
53 // Create a manual kick vector where only the z-coordinate has a value separate from zero
54 vector kick_vector = <0.0,0.0,0.0>;
55
56 // Apply the kick vector to the ball
57 llApplyImpulse(kick_vector, FALSE);
58 }
59 }

Back to the Best Free Tools in Second Life and OpenSim.