Announcement

Collapse
No announcement yet.

recoil

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    recoil

    How would i go about doing some simple recoil.

    #2
    step 1:

    explain to everyone what youre talking about, so someone who might know the answer can answer you.

    Comment


      #3
      Recoil on a gun, you know when you go bang bang it moves Usually creating a vertical and random throw motion on the gun making it inaccurate.

      Comment


        #4
        Well the minigun shakes the view so you could look at the code for that. That's somewhere to start.

        Comment


          #5
          Nar, thats just visual shake it affects nothing.

          Comment


            #6
            Well look through the playercontroller class. There must be some function that allows you to force the player's view to rise.

            Comment


              #7
              Couldnt find anything.

              Comment


                #8
                look at the avril code - when fired, the avril throws the player back a way... might be what you need

                Comment


                  #9
                  Now this all depends on what kind of recoil you want. Ive gone for recoil that happens AFTER you fire the weapon, your first shot is usually very accurate as its the effect of the gun firing that moves you off view. Look into the firemode of a weapon, and just after it does a "trace" to work out if the bullet hit anything, you can shift the rotation that the player is looking at. To do this look at the SetRotation function of a player.
                  If you want to recoil before the bullet is fired, then apply the offset before calling the trace function.

                  btw this is all from memory but the idea should be right

                  Comment


                    #10
                    I cant see a trace function anywhere in the firemode class.

                    Comment


                      #11
                      As I said, its from memory, so just do a search for it in the code, look up DoTrace.

                      Comment


                        #12
                        No results

                        Comment


                          #13
                          Well I dont believe that, I was working on that function all last night. Are you sure your searching the whole of the UT2004 code ?

                          Comment


                            #14
                            its in InstantHit.uc.

                            Code:
                            function DoTrace(Vector Start, Rotator Dir)
                            {
                                local Vector X, End, HitLocation, HitNormal, RefNormal;
                                local Actor Other;
                                local int Damage;
                                local bool bDoReflect;
                                local int ReflectNum;
                            
                            	MaxRange();
                            
                                ReflectNum = 0;
                                while (true)
                                {
                                    bDoReflect = false;
                                    X = Vector(Dir);
                                    End = Start + TraceRange * X;
                            
                                    Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);
                            
                                    if ( Other != None && (Other != Instigator || ReflectNum > 0) )
                                    {
                                        if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
                                        {
                                            bDoReflect = true;
                                            HitNormal = Vect(0,0,0);
                                        }
                                        else if ( !Other.bWorldGeometry )
                                        {
                            				Damage = DamageMin;
                            				if ( (DamageMin != DamageMax) && (FRand() > 0.5) )
                            					Damage += Rand(1 + DamageMax - DamageMin);
                                            Damage = Damage * DamageAtten;
                            
                            				// Update hit effect except for pawns (blood) other than vehicles.
                                           	if ( Other.IsA('Vehicle') || (!Other.IsA('Pawn') && !Other.IsA('HitScanBlockingVolume')) )
                            					WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other, HitLocation, HitNormal);
                            
                                           	Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
                                            HitNormal = Vect(0,0,0);
                                        }
                                        else if ( WeaponAttachment(Weapon.ThirdPersonActor) != None )
                            				WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other,HitLocation,HitNormal);
                                    }
                                    else
                                    {
                                        HitLocation = End;
                                        HitNormal = Vect(0,0,0);
                            			WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other,HitLocation,HitNormal);
                                    }
                            
                                    SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, ReflectNum);
                            
                                    if (bDoReflect && ++ReflectNum < 4)
                                    {
                                        //Log("reflecting off"@Other@Start@HitLocation);
                                        Start = HitLocation;
                                        Dir = Rotator(RefNormal); //Rotator( X - 2.0*RefNormal*(X dot RefNormal) );
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                            windows search feature, so easy to use no one knows why no one uses it.

                            Comment


                              #15
                              Funny, i just found it via windows search feature. Yer windows search in files is a good thing to use.

                              Comment

                              Working...
                              X