Announcement

Collapse
No announcement yet.

Arrow Impalement - How to do this?

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

    Arrow Impalement - How to do this?

    I am trying to create a form of arrow system, and I have looked at every single related article to arrows and Hit Attachments and everything... I just don't understand.


    I am trying to create a system where your player fires an arrow at an enemy.
    When the arrow hits the enemy, it gets the location of where it is hit,
    It then finds the closest bone, and attached itself to the bone
    After attachment, it will base its movement on the movement of that bone (Rotation and Location)


    Please someone help!!!
    Thank you ahead of time

    #2
    Search the forums, there was one thread where there was full code for the bow and arrow, maybe a month ago.

    Comment


      #3
      You have to use SetBase on the arrow and set it to be based on the enemy it hit and just let it idle after that. The rest should updated automatically.

      Though you might want to make a "dummy Actor" for the arrow attachment that has nothing more than the mesh, so you can spawn one of these instead of having all the additional properties of the original arrow projectile stay around and hog memory. Since spawning is a rather expensive operation, you may want to look into pooling those dummies then and just hide/unhide them whenever a new one is needed.

      Comment


        #4
        I'm not sure what spawned all those pooling recommendations lately, but I recommend ignoring them. The Unreal Engine 3 comes with a good garbage collector and spawning only is expensive if done in huge amounts or with replicated actor types. An array mesh stuck in a pawn doesn't really belong in either category, as you'd only have one arrow mesh per hit and ideally it would be spawned as client-only visual effect. In fact, it might be worth trying to create and attach the mesh component directly to the pawn without using a separate actor, if possible.

        Comment


          #5
          Originally posted by Wormbo View Post
          I'm not sure what spawned all those pooling recommendations lately, but I recommend ignoring them.
          It's probably more directed at development for mobile devices, where every bit of CPU time is valuable.

          I've seen such recommendations for other engines in that regard as well.

          Comment


            #6
            Thank you everyone for your input, you guys pointed me in the right direction

            Comment


              #7
              I already said it in another thread: The effort of maintaining a pool, resetting actor properties, disabling actors for pooling, re-enabling them when allocating from pool, and all that stuff - it's probably far more complicated than simply spawning an actor the way you want and where you want. The only place where I've seen actor pooling in UE3 so far is the particle actor pool in UT3. And it makes sense - many identical actors that are nothing more than a container for the various particle effects used throughout the game. (If you make the stuck arrow a particle system, you could take advantage of this existing pool.)

              Comment


                #8
                Look at the stingers projectile (stinger shard I beleive). It is designed to pin the pawn to the wall though.

                Comment


                  #9
                  Code:
                  //-----------------------------------------------------------
                  //
                  //-----------------------------------------------------------
                  class ArenaArrow extends Projectile Placeable;
                  
                  
                  var AudioComponent AmbientComponent;
                  
                  var bool bha****Shield;
                  
                  
                  var bool bHasAlreadyHit;
                  
                  var() StaticMeshComponent ArrowMeshComponent;
                  
                  var soundCue ArrowFlyingCue;
                  var soundCue HitWoodArrowCue;
                  var soundCue HitSandArrowCue;
                  
                  simulated event touch(Actor Other,PrimitiveComponent otherComp  , Vector HitLocation, Vector HitNormal)
                  {
                  local vector momentum, HitLoc, HitNorm;
                  
                  local vector ModifiedHitNorm;
                  
                  local Vector TraceStart;
                  local Vector TraceEnd;
                  
                  local Rotator HitRotation;
                  
                  
                  local ArenaPawn OwnerOfTheShield;
                  
                  
                  TraceStart = location;
                  TraceEnd = Location + (vector(Rotation) * 100);
                  
                  
                  
                  
                  
                  
                  
                    if(!bHasAlreadyHit)
                    {
                  
                  
                      //Shield hit
                      if(ArenaShield(Other) != None)
                      {
                  
                      HitRotation = rotation;
                      SetPhysics(PHYS_None);
                      bha****Shield = true;
                      bHasAlreadyHit = true;
                  
                      ModifiedHitNorm = HitNormal;
                      ModifiedHitNorm.Z = 0;
                  
                      SetLocation(Location + (ModifiedHitNorm *20) );
                      SetBase(ArenaShield(Other),,ArenaShield(Other).SkeletalMcomponent,'Bone');
                  
                      PlaySound(HitWoodArrowCue,,,,Location);
                  
                      //Play the shield block anim
                      OwnerOfTheShield = ArenaShield(other).ShieldHolder;
                  
                       if(ArenaShield(other).bProtecting)
                       {
                        ArenaMeleeWeapon(OwnerOfTheShield.Weapon).PlayShieldBlock();
                       }
                      //Play the shield block anim
                  
                  
                      AmbientComponent.Stop();
                      }
                  
                     if(Other != owner)
                     {
                  
                      //DrawDebugLine(TraceStart,TraceEnd,0,0,255,true);
                  
                        if(Pawn(Other) != none && TraceComponent(HitLoc,HitNorm,ArenaPawn(other).mesh,TraceEnd,TraceStart) && !bha****Shield)
                        {
                         Other.TakeDamage(30, Instigator.Controller, location, Momentum, class'ArenaPenetrateDamage',,self);
                         SetPhysics(PHYS_None);
                  
                         SetLocation(HitLoc);
                         setBase(other,,Pawn(other).mesh,Pawn(other).mesh.FindClosestBone(HitLocation));
                  
                             AmbientComponent.Stop();
                  
                         bHasAlreadyHit = true;
                        }
                  
                  
                     }
                  
                      if(InstancedFoliageActor(Other) != none)
                      {
                       SetPhysics(PHYS_None);
                  
                      }
                  
                    }
                  
                  }
                  
                  
                  
                  //simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal)
                  //{
                  
                  
                  //}
                  
                  simulated event HitWall(vector normal, actor wall, PrimitiveComponent wallComp)
                   {
                        AmbientComponent.Stop();
                  SetPhysics(PHYS_None);
                   bHasAlreadyHit = true;
                   PlaySound(HitSandArrowCue,,,,location);
                   }
                  
                  
                  
                  event tick(float DeltaTime)
                  {
                  	super.tick(DeltaTime);
                  
                  
                  	 velocity.Z -= 98*DeltaTime*3;
                  
                  }
                  
                  
                  function init(vector Direction)
                  {
                  
                  	super.Init(Direction);
                  
                     if(ArrowFlyingCue != none)
                     {
                     AmbientComponent = CreateAudioComponent(ArrowFlyingCue, true, true);
                     }
                  
                  
                  
                  }
                  
                  
                  DefaultProperties
                  {
                  Begin Object class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
                  bEnabled=TRUE
                  End Object
                  Components.Add(MyLightEnvironment)
                  
                  begin object class=StaticMeshComponent Name=BaseMesh
                  LightEnvironment=MyLightEnvironment
                  end object
                  
                  
                  bRotationFollowsVelocity=true
                  
                  Components.Add(BaseMesh)
                  CollisionComponent = BaseMesh
                  ArrowMeshComponent  =  baseMEsh
                  
                  bCollideComplex = true;
                  
                  
                  ArrowFlyingCue = SoundCue'GOTASounds.ArcherySounds.ArrowFlyingCue'
                  HitWoodArrowCue = SoundCue'GOTASounds.ArcherySounds.HitWoodArrowCue'
                  HitSandArrowCue = SoundCue'GOTASounds.HitProjectilesReactions.ArrowGetStuckOnSandSound'
                  
                  
                  speed=1000
                  lifeSpan = 100000
                  }

                  This arrow Works , use this as sample if you want , about the collision settings you may have to archetype it sorry heh.

                  it gets stucked in pawns shields and some of this and some of that... xd

                  Comment


                    #10
                    Interesting... Thanks everyone You surely helped a lot. Kudos to everyone who is making games with arrow-like impalement!

                    Comment


                      #11
                      thanks to you i learnt a new Word , impalment mmmh interesting : P sounds gore.

                      Comment

                      Working...
                      X