Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Radio Controlled Vehicle..

Davy Flytrap
Registered User
Join date: 21 Feb 2005
Posts: 146
06-11-2005 16:36
Hello there,

Im working on a radio controlled vehicle and im using llShout() on a different channel.

On the object that listens for the llShout(), it only seems to do what it says some of the time, or if i nudge it, click it or whatever, it works fine for 2-3 secs then stops and it will require me to click or nudge it again..

Please help me sombody.

Thanks in advance..

Regards Davy
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
06-11-2005 17:38
Post the code?

llShout also only has a range of 100m.
_____________________
---
Davy Flytrap
Registered User
Join date: 21 Feb 2005
Posts: 146
06-11-2005 17:49
CODE
float forward_power = 30; //Power used to go forward (1 to 30)
float reverse_power = -15; //Power ued to go reverse (-1 to -30)
float turning_ratio = 4.0; //How sharply the vehicle turns. Less is more sharply. (.1 to 10)

default
{
state_entry()
{
llListen(0, "", NULL_KEY, "");

llSetTimerEvent(1);
llSetVehicleType(VEHICLE_TYPE_CAR);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.80);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.2);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.5);
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000.0, 2.0, 1000.0> );
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <10.0, 10.0, 1000.0> );
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.50);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.50);
}

listen(integer channel, string name, key id, string message)
{
integer reverse=1;
vector angular_motor;

vector vel = llGetVel();
float speed = llVecMag(vel);

if(message == "FWD")
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power,0,0> );
llSay(0, "Going Forward");
}else if(message == "BACK")
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <reverse_power,0,0> );
llSay(0, "Going Backward");
}else if(message == "LEFT")
{
angular_motor.z += speed / turning_ratio * reverse;
}else if(message == "RIGHT")
{
angular_motor.z -= speed / turning_ratio * reverse;
}

//llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);

}

timer()
{
llResetScript();
}
}


Where is says llSay(0, "Going Backward";);, that is just confirming that it is recieving the message.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
06-13-2005 20:52
This is getting a bump because I referred Davy back to this thread in-world, and it's not gotten an answer yet.

While I know several ways of going about this, I don't trust email or shout to be effective or fast enough for this. Any suggestions?

llShout is the only effective solution that comes to mind, but that doesn't seem good for multiple sims. :o
_____________________
---
Bret Hornet
Registered User
Join date: 6 Jun 2005
Posts: 29
06-13-2005 20:58
Not sure if this is the problem, but you realize you're resetting your script once a second right?
Bret Hornet
Registered User
Join date: 6 Jun 2005
Posts: 29
06-13-2005 21:04
Also realized the code is not checking who said something, so it's going to run everytime someone says something. Not sure if you removed other code that sets parameters, but if you did, they're getting called everytime anyone says something...

Since you're only doing

CODE

integer reverse=1;
vector angular_motor;

vector vel = llGetVel();
float speed = llVecMag(vel);


outside the command checks, it probably won't hurt anything, but if you are setting other params down below, then someone saying something could be messing you up...
Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
06-15-2005 13:43
Just a suggestion, but I made an RC car a while back, and coded it more like a vehicle, setting vehicle type, etc.

I actually had it take the user's controls to drive the car as they might a full-size vehicle. Loads of fun, but a little difficult to work with camera angles. The idea was to eventually build a racetrack/obstacle course and have races.

From: Davy Flytrap
Hello there,

Im working on a radio controlled vehicle and im using llShout() on a different channel.

On the object that listens for the llShout(), it only seems to do what it says some of the time, or if i nudge it, click it or whatever, it works fine for 2-3 secs then stops and it will require me to click or nudge it again..

Please help me sombody.

Thanks in advance..

Regards Davy
Zindorf Yossarian
Master of Disaster
Join date: 9 Mar 2004
Posts: 160
06-16-2005 16:44
Having the vehicle take your controls may be the best solution. The problem is that when it has your controls you can't do anything else. (Yes, you can pass the control, but that would be even worse.) You could toggle whether or not it takes your controls with a shouted command, or a keypress. That would rock.
_____________________
Badass Ninja Penguin: Killing stuff it doesn't like since sometime in May 2004.