Author Topic: Using multiple raycasts with the same weapon image?  (Read 599 times)

 Would anyone know how to use two or more raycasts with the same weapon image? Basically, I'm looking into a laser pointer on a weapon but have been having issues, so I thought of using two raycasts to do the job of pointing then also actually firing the weapon.

Raycasts are 100% script. You could do hundreds in one function if you want. The way that raycast sniper rifles work is by using multiple 100 distance raycasts to ensure accuracy.

I've look at a script that used a raycast, but I didn't see anything in the fire function that hinted to using a specific raycast.

Look for a Support_Raycast.cs in the file. Most raycasting weapons use what I called the "Spacecasting" system which was developed by SpaceGuy and tweaked by yours truly.

Alright, I'll check into that.

Sorry, but I'm still in the dark. I've had a look through version 2 of the raycast support script and I'm without enlightenment. Would you be able to offer any suggestions as to how to interchange between two raycasts somehow? I haven't noticed any way to specify a certain raycast at a given time.

I don't know what you're asking.

If you want some sort of laser pointer script you're in for a hackfest.

Package WeaponImageName::onMount(%this, %obj, %slot) and start a loop, like %player.doLaserPointer(). in doLaserPoint(), schedule a new laser point every 100ms or so.

In WeaponImageName::onUnMount(...), cancel that schedule.

That's how I'd do it.

Ok, basically, I've been using a raycast projectile to simulate a laser pointer. However, I'm wanting another raycast projectile to function as the actual weapon's projectile, in my case a rocket. I plan to have the rocket act as the "tracer" of the second raycast. But, I don't know of anyway to have two raycast projectiles and their accompanying data stored in the same weapon image and how to actually call for either raycast projectile.

Resolution Found!

I finally found a way for this to work! All I really needed was just one raycast projectile. In the "onFire" function of Tier + Tactical 2's pistol script are these code snippets:
Code: [Select]
%this.raycastSpreadAmt = 0.0018;
%this.raycastWeaponRange = 85;
Since the raycast projectile IS 100% script as you have mentioned, it is dynamic in that it can be modified on the fly. I took advantage of this and added these two script snips to two different functions:
Code: [Select]
%this.raycastTracerProjectile = NULLProjectile;
Code: [Select]
%this.raycastTracerProjectile = LightRocketProjectile;
This enabled the weapon image to have two different projectiles spawned with the same raycast at different times.