Author Topic: Radar/Speed Gun  (Read 1695 times)

Against my best efforts and inability to code, it'd be nice to have for a server I host.

If someone could throw together a code to get this started I could happily package/model the rest.
Essentially just a centerprint readout of the speed of a vehicle the gun is pointed at.
« Last Edit: April 13, 2020, 11:09:05 PM by Tekari »

good luck actually hitting the speeding vehicle because its collision box will always teleport ahead as part of the executive netcode suite

hmm maybe i could whip something up....

might be possible to loop over all the vehicles and check if it's going to be anywhere near where the player is aiming
not great, but there isn't that many vehicles

might be possible to loop over all the vehicles and check if it's going to be anywhere near where the player is aiming
not great, but there isn't that many vehicles
this is what i was thinking too. get every vehicle within a sane distance, create vectors to each of them, compare vectors with eye vector and if within a certain angle consider it a hit, essentially giving you a circle in the middle of your screen that can detect any vehicle inside of it without having to try to nail a hitbox with a raycast

I modified the default gun to work like a speed gun pretty easily. It fires projectiles while you hold down click.

Here is a video example



this was just a test though, it could certainly be made into a much better add-on

I modified the default gun to work like a speed gun pretty easily. It fires projectiles while you hold down click.

Here is a video example



this was just a test though, it could certainly be made into a much better add-on
i wanna try making an add-on or at least a .dts for an add-on so can i have this

Make it a bot weapon with a node-based display so you can print the speed directly on the gun instead of centerprint. Or no balls

Does blockland have default functionality for getting every vehicle in the server? This function should work, can increase $RadarGunTolerance if it's too hard to hit vehicles

Code: [Select]
$RadarGunTolerance = 0.1;
function Player::captureVehicleSpeed(%player)
{
%ev = %player.getEyeVector();
%pos = %player.getEyePoint();

%closestDist = 999;
%closest = "";

for(%i = 0; %i < $VehicleSet.getCount(); %i++)
{
%vehicle = $VehicleSet.getObject(%i);
%toVehicle = vectorNormalize(vectorSub(%vehicle.getPosition(), %pos));
%angle = mACos(vectorDot(%toVehicle, %ev));

if(%angle <= $RadarGunTolerance)
{
%dist = vectorDist(%pos, %vehicle.getPosition());
if(%dist < %closestDist)
{
%closestDist = %dist;
%closest = %vehicle;
}
}
}

if(isObject(%closest))
{
return vectorLen(%closest.getVelocity());
}
}

package RadarGun
{
function WheeledVehicleData::onAdd(%this, %vehicle)
{
if(!isObject($VehicleSet))
$VehicleSet = new SimSet();

Parent::onAdd(%this, %vehicle);
$VehicleSet.add(%vehicle);
}

};
ActivatePackage(RadarGun);

will have to add raycast checks if you care about it seeing through walls
« Last Edit: April 16, 2020, 04:37:58 PM by Crook »

I modified the default gun to work like a speed gun pretty easily. It fires projectiles while you hold down click.

Here is a video example

-snip-

this was just a test though, it could certainly be made into a much better add-on
Can you release/DM the zip for this? This seems to be the easiest solution so far and works pretty well, I could work it into a more refined and ready-to-use version once I throw a model together, unless someone else more talented would like to volunteer to.

Make it a bot weapon with a node-based display so you can print the speed directly on the gun instead of centerprint. Or no balls
lol. Although that idea does seem cool I'm not trying to go all out here as it might take a while with my schedule, but if you want to do that it would certainly be a feat!

i wanna try making an add-on or at least a .dts for an add-on so can i have this

Can you release/DM the zip for this? This seems to be the easiest solution so far and works pretty well, I could work it into a more refined and ready-to-use version once I throw a model together, unless someone else more talented would like to volunteer to.

https://forum.blockland.us/index.php?topic=325638.0
« Last Edit: April 17, 2020, 12:27:43 AM by Goth77 »