Monday, 8 November 2010

guns, flying saucers and other miscelaneous terror!

Seriously falling behind here, useless at blogging heres weeks 3 and 4.

Week 3 Ressing objects - this was alot of fun and relatively simple to do once i got the hang of the gun mechanics, the barn door was pretty simple and the code is pretty straight forward:

default
{
    state_entry()
    {
       // llSay(0, "Hello, Avatar!");
    }

    collision_start(integer total_number)
    {
        llOwnerSay(llDetectedName(0) +"::"+ (string)llVecMag(llDetectedVel(0)));
        llOwnerSay(llKey2Name(llDetectedOwner(0)));
        //llOwnerSay(llDetectedName(0) +"::"+ (string)(llDetectedVel(0)));
    }
}

 Week 4 was much more interesting and dealt with the movement of objects i enjoyed this lecture alot and played about with the physics of gravity in second life to create a flying saucer and creating some simple movement commands to send the ufo flying away from me for a few seconds, stop then fly back. Here is the code:
default
{
  
    touch_start(integer total_number)
    {
        llOwnerSay("Touched. Starting Flight");
           float mass = llGetMass(); // mass of this object
           float gravity = 9.8; // gravity constant
        llSetForce(mass * <0,0,gravity>, FALSE); // in global orientation;
       
        llApplyImpulse(llGetMass()*<0,5,0>,FALSE);
        state time;
      
    }
   
   
}
    
state time
    {
    state_entry()
        {
            llSetTimerEvent(5);
        }
   
     timer()
        {  
            llApplyImpulse(llGetMass()*<0,-10,0>,FALSE);
            state time2;
        }  
               
    }
   
state time2
    {
    state_entry()
        {
            llSetTimerEvent(5);
        }
     timer()
        {
            llApplyImpulse(-llGetMass()*llGetVel(),FALSE);
            state default;
        }
    } 

By using impulse i get a steady movement which can sometimes go a little crazy when it hits something but here are some images of the heart of gold (brown taurus!) in action:







Pictures of a moving object dont work very well but its there and it works wonderfully :D

Project
For the amusement park im going to use the movement physics to to create a simple flight sim which will enable the players avatar to get into an aircraft and fly through a series of moving targets in a specific time limit. The user will gain points for each target they fly through and this will be posted with the times of other players in notecard form. The vehicle will use the inbuilt vehicle commands and the targets will use timed impulse movements such as the one used in the above flying saucer.

No comments:

Post a Comment