Author Topic: help needed on raycasts  (Read 706 times)

i want to fix the problem of no good flashlights, but i need to know how to use the raycasting script.

all I want to do is create a light at the first collision in a direct line from the flashlight, but i was thinking of using the raycast script with a projectile with light that doesn't hurt people. Obviously any work arounds would be appreciated as well as a simple explanation of either how raycasting works or how the script which was developed works.

Thankyou

What raycasting script are you referring to?

What he's asking for is instructions on how to use raycasts.

all i want to do is instantly place a light on the nearest surface to the "flashlight" within a certain distance. if possible, dim the light as it gets farther, but thats a lill far fetched. Im new to torque syntax.

Instructions on raycasts...
I believe Space Guy could help you for most of it, since he made the raycasting weapons support.

The support for raycasting weapons is used in the tier tactical weapons and more.

To make a weapon use raycasting, you put the script file Support_RaycastingWeapons.cs in with your Add-On (can be found in various places e.g. TF2 Basic Guns, Tier+Tactical), exec() it then add several of these attributes to the ShapeBaseImageData weapon you want to use it:

raycastWeaponRange - Required. The distance it fires for e.g. flashlight doesn't work at long distances.

raycastWeaponTargets - What it collides with. Use this to make it go through players and only shine on walls:
Code: [Select]
   raycastWeaponTargets =
                   $TypeMasks::StaticObjectType |
                   $TypeMasks::TerrainObjectType |
                   $TypeMasks::VehicleObjectType |
                   $TypeMasks::FXBrickObjectType;

raycastExplosionProjectile - A Projectile datablock. You cannot directly spawn "Explosion" objects for particles/lighting effects so if needed use a 10-20ms lifetime projectile.

raycastDirectDamage - Unimportant for a flashlight.
raycastDirectDamageType - Same.

raycastSpreadAmt - This causes the ray to have a random spread.
raycastSpreadCount - Number of rays to fire per shot.

raycastTracerProjectile - Optionally fires a different projectile datablock down the path of each shot.

This affects WeaponImage::onFire so if your gun uses a modified firing method (e.g. the Gun's "move hand up" animation) then you must call Parent::onFire(%this,%obj,%slot) or it won't work.

You can also adjust your weapon's ::onHitObject or ::onRaycastDamage functions (arguments %this,%obj,%slot,%col,%pos,%normal,%shotVec) similarly to Badspot's Projectile::onCollision/onDamage functions to have different effects on hit.


One thing is that the last flashlight made in this way (with a short-lived explosion with a light radius wherever you aimed it) kept flickering if there was any lag at all.

there's got to be a way to create one light, almost like a projectile that never disappeared, and teleport it to the raycast. that would work.

anyways, thanks Space Guy.