Talk:Projectile based Weapons

From Valve Developer Community
Jump to: navigation, search

I'm pretty sure they're dissapearing when you spawn like that because they're all colliding with eachother. you'll need to add a collision group check so that those types of projectiles can't hit eachother.

if that's not it, well not sure then, but it sure sounds like it. --omega

possibly yes, that was my first guess too. Though I tried lining them up with a neat amount of space, and they still disappear, and as far as I can tell, before there is a chance of them colliding. I also checked the CCrossbowBolt::BoltTouch method, but it only collides with NPC's and non-moving objects, as far as I could tell. I should have mentioned both in the article I guess, sorry. Corner 14:31, 16 Jun 2006 (PDT)
alright, but the touch function doesnt prevent it from colliding higher up in the actual movement heirarchy; which was why i suggested that. I dont have time this moment to try it (heading to work) but I seriously suggest creating a new collision group, ie: COLLISION_GROUP_BOLT and put a check in ShouldCollide itself: if (collisiongroup0 == COLLISION_GROUP_BOLT && collisiongroup1 == COLLISION_GROUP_BOLT) return false; that would eliminate once and for all if thats indeed the problem. --omega
Ok thanks, I did not know that. Now I haven't looked at it further since my last reply, but when I have some spare time again I will do as you suggest. Corner 05:08, 20 Jun 2006 (PDT)

Just a quick observation. It looks as if the origin and angle are passed by refrence in BoltCreate, possibly they are all getting spawned with their own positions and then the next tick getting updated to the last created? It would explain the results you were getting. Don't quote me on this though, have yet to test it, still trolling through the mass of code x_x. (First edit, excuse me if I posted this wrong) --Scuz3d 01:23, 23 Aug 2006 (PDT)

Looks like that isnt it 'hmmmm. Did some testing, when I didnt include the player as the owner I got most of the bolts to fire/hit-something more frequently, making me wonder whether the extra bolts are colliding with the player? One thing to note, if you do try it without setting yourself as the owner, make sure to enter god mode, the blood is cool though 'shrug--Scuz3d 01:02, 24 Aug 2006 (PDT)

Physgun interaction with projectiles

Would be pretty cool if you could use the physgun on projectiles (rockets or bolts). Someone asked me the other day if you could snag an RPG rocket w/the grav gun. Really not sure but it would be fun if you could.

Interesting Question, I think I will look into it. Corner 23:06, 16 Jun 2006 (PDT)

Weapon Recoil

I have been looking through the source of weapon_crossbow and was wondering how you change the recoil on the gun. I'm currently in the process of creating an auto-crossbow, but the recoil is ridiculous. I found what I believe to be the code controlling the recoil.

 pOwner->ViewPunch( QAngle( -2, 0, 0 ) ); 

After commenting it out and noticing no changes I am lost. Any info would be appreciated. -paste120 3:27 AM 06/13/07

Feedback

"This changes the x and y angles with up to 2.5 degrees in either direction. This actually results in a square spread instead of a cone, but at least it works. If anybody knows of a better approach, I would be happy to hear about it."

The perfect aiming point (the spot in the centre of the screen inicated by the crosshair) is your vector O. Now get a random distance and angle. Having that simply calculate the spread vector with this two formulas:
Y = Sin(th) * R
X = Cos(th) * R
Now add X to O.X and Y to O.Y
Where X and Y are the displacement values, th is the angle and R is the distance.
Hope that helps. --FALCO 07:09, 24 Jan 2007 (PST)

Method to add imperfect aiming

Why not just add an exponent? The further the projectile travels the greater the inacuracy? (not too large an exponent though) Y=R^a x=R^a would need to make 'a' a random value between two set values t get different arcs each time. A cool idea would be that the value of 'a' could be amlpified by the value of proximity entity that also triggers a wind sample. --o0OpsyphiO0o 16:36, 14 Aug 2008 (PDT)

Replace projectile?

hi! is there any way to change the projectile of a weapon. I cant seem to find out how. --Lazy genius 01:39, 14 April 2009 (UTC)