Projectile spreading
by gamer · in Torque Game Engine · 05/31/2006 (11:29 am) · 2 replies
Hi,is there some kind of weapon spreading already in the engine? I discovered this resource for projectile spreading http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1714, but I am wondering if something similar already exists in the engine since that resource is old.
thanks!
thanks!
About the author
#2
06/01/2006 (11:45 am)
Thank you, that is wonderful. I have also decided to use camera shake in combination with this.
Torque Owner Paul /*Wedge*/ DElia
I use a much simpler method of just giving random offsets to the weapon's muzzle vector for my fire spreading. I have a couple stupid functions that are a bit needlessly complex, you could make it simpler than this. The point is just to add equal random +/- ranges to each of the vector components.
//Fake, cheap, and very effective vector scattering functions //Recommended entry values for amount are 0-10 function ScatterVector(%vector, %amount){ return vectorAdd(%vector, ScatterAngle(%amount) SPC ScatterAngle(%amount) SPC ScatterAngle(%amount) ); } //Support function for ScatterVector function ScatterAngle(%angle){ %angle *= 100; return (getRandom(%angle * -1, %angle) / 10000); }So you just have those two functions in your code somewhere and in your weapon's onFire you callWhere the number is the amount of spread you want. I think I use 8 for the shotguns in my game.