Announcement

Collapse
No announcement yet.

[VIDEO][FAST ALGORITHM] Draw Thrown Projectile Pathing, Shows Predicted 3D Bounces

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

    #16
    Well, the thing is I'm not supposed to have my inherited class in game Ever. I would just like the code to be on one and only weapon class instead of my 4 other classes.
    Also, I don't understand what you want to say when you say "targetting feature".

    In fact, my real Weapon classes are all inherited from UDNWeapon, in which I copy/past your code, which is inherited from UTWeapon.

    One example from my 4 weapons classes :

    Code:
     
    
    class UDNWeap_Champi_Platform extends UDNWeapon;
    
    
    
    defaultproperties
    {
            WeaponFireTypes(0)=EWFT_Projectile
            WeaponProjectiles(0)=class'UDNProj_Champi_Platform'
    
    	FireOffset=(X=16,Y=10)
    
    	CurrentRating=+0.75
    	bInstantHit=false
    	bSplashJump=false
    	bRecommendSplashDamage=false
    	bSniping=false
    	bCanThrow=false
    
    	AmmoCount=1
    	LockerAmmoCount=1
    	MaxAmmoCount=1
    	
    	InventoryGroup=1
    }
    Code:
    class UDNWeapon extends UTWeapon;
    
    var UDNPlayerController pc;
    
    var vector throwDir;
    var vector pawnRot;
    var vector spawnLoc;
    var UDNProj_Pathway p;
    
    //============Display Path ============
    var YourProjectilePathNode pathNodes[40]; 
    var UDNProj_Pathway tracer;
    var int curPathNodeCount;
    //=================================
    
    var int v;
    var vector vc;
    var YourProjectilePathNode pnode;
    
    
    simulated function PostBeginPlay()
    {
    	
    	//~~~~~~~~~~~~~~~~~~~~~~~~
    	super.PostBeginPlay();
    	//~~~~~~~~~~~~~~~~~~~~~~~~
    	pc = UDNGameInfo(WorldInfo.Game).CurrentPlayer;
    
    	createNodesRunOnceEntireGame();
    }
    
    //============ Draw Path ===============
    
    
    //=================
    //Memory Management
    //=================
    
    //Create Once For Entire Life of this Weapon
    function createNodesRunOnceEntireGame()
    {
    	for (v = 0; v < ArrayCount(pathNodes); v++ )
            {
    		
    		//last spawn parameter makes sure spawning occurs regardless of obstructing collision
    		pnode = spawn(Class'YourProjectilePathNode',,,
                                                     pc.pawn.Location, rot(0, 0, 0),, true);
    		
    		//pnode.staticmeshcomponent.setMaterial(0);
    		pathNodes[v] = pnode;
    		
    		//pc.optimize("node set"@v);
    	}
    	
    	//hide from view
    	clearPathNodes();
    }
    
    //when this class is destroyed,
    //destroy the objects spawned into world
    //to act as path node indicators
    
    //this is an actor event and is called by unreal engine
    simulated event Destroyed()
    {
    	super.Destroyed();
    	for (v = 0; v < ArrayCount(pathNodes); v++ ) 
            {
    		if (pathNodes[v] == none) continue;
    		pathNodes[v].destroy();
    	}
    }
    
    
    function stopDrawingPathNodes() 
    {
    	
    	if(tracer != none)
            {
    		tracer.destroy();
    	}
    	ClearTimer('drawPathNodes');
    	clearPathNodes();
    }
    
    
    function startDrawingPathNodes()
    {
    
    	//already running
    	if (isTimerActive('drawPathNodes')) return;
    	
    	//clear any remaining previous path nodes
    	//clearPathNodes();
    	
    	//throw the tracer
    	tracer = throwTracer();
    
    	//hide
    	tracer.setHidden(true);
    	
    	curPathNodeCount = 0;
    	SetTimer(0.01, true, 'drawPathNodes');
    	
    	//max life span of 12 seconds
    	SetTimer(12, false, 'clearPathNodes');
    }
    
    
    
    function drawPathNodes() 
    {
    	
    	//end case
    	if (curPathNodeCount >= ArrayCount(pathNodes) ) {
    		ClearTimer('drawPathNodes');
    		return;
    	}
    	
    	//lost tracer case
    	if (tracer == none) {
    		ClearTimer('drawPathNodes');
    		return;
    	}
    	
    	positionPathNode();
    	
    }
    
    
    function clearPathNodes() 
    {
    	
    	//position doesnt update if hidden for some reason
    	//so move node way far away from player to simulated being hidden
    	//still faster than spawning/destroying
    	
    	//would like to know how to make location update properly even while its hidden
    	//some sort of low-level or native optimization that is getting in the way here
    	for (v = 0; v < ArrayCount(pathNodes); v++ ) {
    		
    		//set the loc
    		vc.x = (v + 1) * 4000;
    		vc.y = (v + 1) * 4000;
    		vc.z = pc.pawn.Location.z - (v + 1) * 4000;
    		
                    //make sure not going below killz
                    if (vc.z < worldinfo.killz) 
    			vc.z = worldinfo.killz + 5;
    		
    		pathNodes[v].move(pc.pawn.Location + vc - pathNodes[v].Location);
    	}
    }
    
    
    function positionPathNode() 
    {
    	
    	//end case
    	if (curPathNodeCount >= ArrayCount(pathNodes)) return;
    	
    	//lost the tracer
    	if (tracer == none) return;
    
    	//move is way faster than SetLocation
    	//this code says "move path node the amount that is the difference
    	//between its current location and the desired goal position"
    	pathNodes[curPathNodeCount].move(
                               tracer.Location - pathNodes[curPathNodeCount].Location
            );
    	
    	curPathNodeCount++;
    }
    
    
    function UDNProj_Pathway throwTracer() 
    {
    
    	//pc is ref to your controller class
    	//see my other tutorials on giving
    	//this class a ref to your pc using
    	//post begin play
    	pawnRot = Vector(pc.pawn.Rotation);
    	throwDir = pawnRot;// * 1000;
    	throwDir.z *= 3;
    	
    	spawnLoc = pc.pawn.Location + pawnRot * 64;
    	spawnLoc.z += 64;
    	
    	//spawn
    	p = spawn(Class'UDNProj_Pathway',,, spawnLoc, rot(0, 0, 0) );
    	
    	//init
    	//p.InitializeProjectile(pc, throwDir);
    
            //implementation dependent
    	return p;
    }
    
    
    
    defaultproperties
    {
    }
    There's no Firing Process over these codes, actually, I think you'll have to help me out finding it in UTWeapon Class.

    Part in italic is what I suppose to be the part when my "scout" projectile (called UDNProj_Pathway) is spawned.
    I had to add lots of variables, and change such things as UDNGameInfo, 'cause I didn't have created these classes yet, and I got many errors from UnrealFrontend.

    Now I don't get any errors or warnings, but I don't get no traces in game. My weapon class UDNWeapon is not working, even if I assign a Projectile to itself, but my UDNProj_Pathway is.

    Sorry for my misunderstanding, and for my english too, young french guy who's trying to figure out things in someone's else language... ^^'

    Comment


      #17
      Would it be possible to make a grenade system that works like this:?



      Uploaded with ImageShack.us

      The main Idea is that in addition to the path (Whick from what I can see is a sphere imported into udk) , There would also be a decal on the floor location (where the grenade lands and explodes) . And the radious of the decal can be adjusted by increasing or decreasing the explosion radious of the projectile.

      Comment


        #18
        It should be quite simple to do that kelt'ar. Using Evernewjoy's method you could have the projectile spawn a decal or particle effect to mark the explosion radius when it 'explodes', or simply when it reaches the end of the array.

        Comment


          #19
          Up ! Sorry to ask, but I'd really need your help for this ^^ Last feature missing in my game é_è !

          Code:
          }
          function YourProjectileObject throwTracer() {
          	
          	//pc is ref to your controller class
          	//see my other tutorials on giving
          	//this class a ref to your pc using
          	//post begin play
          	pawnRot = Vector(pc.pawn.Rotation);
          	throwDir = pawnRot;// * 1000;
          	throwDir.z *= 3;
          	
          	spawnLoc = pc.pawn.Location + pawnRot * 64;
          	spawnLoc.z += 64;
          	
          	//spawn
          	p = spawn(Class'YourProjectileObject',,, spawnLoc, rot(0, 0, 0) );
          	
          	//init
          	//p.InitializeProjectile(pc, throwDir);
          	//implementation dependent
          	return p; 
          
          }
          ~~~

          YourProjectileObject Class

          This is implementation dependent, as to whether you are using an actual Kactor or a projectile.

          As I said I wrote my own physics engine for a ut projectile for maximum use in all types of collision including per poly.

          ~~~
          I think I'm still missing this part, actually I do not know how to reference my own projectile in my weapon classes as I don't have any code for this, my firing process is all inherited from UTWeapon, and I didn't overwrite this anywhere.

          You've still done everything for my game without even knowing it, if you could just finish helping me with this, it would be really nice !

          Comment


            #20
            Originally posted by Ouroboross View Post
            I think I'm still missing this part, actually I do not know how to reference my own projectile in my weapon classes as I don't have any code for this, my firing process is all inherited from UTWeapon, and I didn't overwrite this anywhere.

            You've still done everything for my game without even knowing it, if you could just finish helping me with this, it would be really nice !
            What projectile class is your current weapon system using?

            Can you post that code?

            Rama

            Comment


              #21
              Code:
              class UDNProj_Champi_Platform extends UTProjectile;
              
              simulated function PostBeginPlay()
              {
              	Super.PostBeginPlay();
              	//SetTimer(10);                  //Grenade begins unarmed
              	RandSpin(100000);
              }
              
              
              /*
              simulated event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
              {
              	local rotator myRot;
                  SetPhysics(PHYS_None);
              
                  MomentumTransfer = 50000;
              
                  if ( Champi(Other) == none || Debris(Other) == none )
              	{
                              if (HitNormal.Z < -0.3)
                              {
                                      //Will Explode
                              }
              
                              else if (HitNormal.X < -0.5)
                              {
                                      //Will Explode
                              }
              
                              else if (HitNormal.X > 0.5)
                              {
                                      //Will Explode
                              }				
              				
                              else if (HitNormal.Z < 0.5)
              				{
                                      myRot = rotator(HitNormal);
              						myRot.Pitch -= 16384;
              						SetRotation(myRot);
                                      SpawnChampi_Wall(Other, vect(0,0,0));
                              }
              
                              else if (HitNormal.X < 0.5)
              				{
                                      //myRot.Pitch = (HitNormal.X * 32768/PI *-0.5);
                                      SetRotation(rotator(HitNormal));
                                      SpawnChampi_Ground(Other, vect(0,0,0));
              				}
              
                              else if ( Champi(Other) != none || Debris(Other) == none)
              		{
                                      //Will Explode
              		}
              	}
              
                      Explode(Location, vect(0,0,1));
              }
              */
              
              
              simulated event HitWall(vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
              {
              	local rotator myRot;
                  SetPhysics(PHYS_None);
              
                  MomentumTransfer = 50000;
              
                  if (HitNormal.Z < -0.5)
                  {
                          //Will Explode
                  }
              
              	else if (HitNormal.Z < 0.75)
              	{
              			myRot = rotator(HitNormal);
              			myRot.Pitch /= 3;
                                      SetRotation(myRot);
              			SpawnChampi_Wall(Wall, vect(0,0,0));
              	}
              
                  else if (HitNormal.X < -0.5)
                  {
                          //Will Explode
                  }
              
                  else if (HitNormal.X > 0.5)
                  {
                          //Will Explode
                  }
              
              	
                  else if (HitNormal.X < 0.5)
              	{
                              if (HitNormal.X < 0)
                              {
              						myRot = rotator(-HitNormal);
                                      myRot.Pitch += 16384;
                              }
              
              				else if (HitNormal.X >= 0)
                              {
                                      myRot = rotator(HitNormal);
              						myRot.Pitch -= 16384;
                              }
              
              	SetRotation(myRot);
              	SpawnChampi_Ground(Wall, vect(0,0,0));
                  }
              
              	else
              	{
              			//will explode
              	}
              
              	self.Destroy();
              	//Explode(Location, vect(0,0,1));
              }
              
              
              simulated function SpawnChampi_Wall(Actor Wall, vector HitNormal)
              {
              	local Actor Champi_Wall;
              
                      Champi_Wall = Spawn(class'UDNChampi_Platform_Wall');
                      Champi_Wall.SetBase(Wall);
              }
              
              
              simulated function SpawnChampi_Ground(Actor Wall, vector HitNormal)
              {
              	local Actor Champi_Ground;
              
                      Champi_Ground = Spawn(class'UDNChampi_Platform_Ground');
                      Champi_Ground.SetBase(Wall);
              }
              
              
              
              /*	bBlockedByInstigator = true;
              
              	if ( WorldInfo.NetMode != NM_DedicatedServer )
              	{
              		PlaySound(ImpactSound, true);
              	}
              
              	// check to make sure we didn't hit a pawn
              
              	if ( Pawn(Wall) == none )
              	{
              		Velocity = 0.75*(( Velocity dot HitNormal ) * HitNormal * -2.0 + Velocity);   // Reflect off Wall w/damping
              		Speed = VSize(Velocity);
              
              		if (Velocity.Z > 400)
              		{
              			Velocity.Z = 0.5 * (400 + Velocity.Z);
              		}
              		// If we hit a pawn or we are moving too slowly, explod
              
              		if ( Speed < 20 || Pawn(Wall) != none )
              		{
              			ImpactedActor = Wall;
              			SetPhysics(PHYS_None);
              		}
              	}
              	else if ( Wall != Instigator ) 	// Hit a different pawn, just explode
              	{
              		Explode(Location, HitNormal);
              	}
              */
              
              
              simulated function PhysicsVolumeChange( PhysicsVolume NewVolume )
              {
              	if ( WaterVolume(NewVolume) != none )
              	{
              		self.Destroy();
                              //Explode(Location, vect(0,0,1));
              	}
              
              	Super.PhysicsVolumeChange(NewVolume);
              }
              
              
              DefaultProperties
              {
                  ProjFlightTemplate=ParticleSystem'WP_RocketLauncher.Effects.P_WP_RocketLauncher_Smoke_Trail'
              
                  ProjExplosionTemplate=ParticleSystem'WP_RocketLauncher.Effects.P_WP_RocketLauncher_RocketExplosion'
                  ExplosionLightClass=class'UTGame.UTRocketExplosionLight'
              
              
                  Speed=500.0
                  MaxSpeed=500.0
                  Damage=26.0
                  DamageRadius=220.0
                  MomentumTransfer=50000
                  MyDamageType=class'UTDmgType_Grenade'
                  LifeSpan=3.0
                  ExplosionSound=SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_Impact_Cue'
                  ExplosionDecal=MaterialInstanceTimeVarying'WP_RocketLauncher.Decals.MITV_WP_RocketLauncher_Impact_Decal01'
                  DecalWidth=128.0
                  DecalHeight=128.0
                  bCollideWorld=true
                  bBounce=false
                  TossZ=+10.0
                  Physics=PHYS_Falling
                  CheckRadius=36.0
              
                  ImpactSound=SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_GrenadeFloor_Cue'
              
                  bNetTemporary=False
                  bWaitForEffects=false
              
              
                  CustomGravityScaling=0.5
              }
              I didn't modify anything over UTProjectile

              Comment


                #22
                Originally posted by Kelt'ar View Post
                Would it be possible to make a grenade system that works like this:?



                Uploaded with ImageShack.us

                The main Idea is that in addition to the path (Whick from what I can see is a sphere imported into udk) , There would also be a decal on the floor location (where the grenade lands and explodes) . And the radious of the decal can be adjusted by increasing or decreasing the explosion radious of the projectile.
                ya that could work, I personally would use a torus shaped static mesh to show the blast radius

                but if you want to spawn decals here's the code I wrote for that

                ~~~

                Spawning Decals

                Code:
                function spawnDecal(vector hitLoc){
                   local MaterialInstanceTimeVarying MITV_Decal;
                
                   MITV_Decal = new(self) class'MaterialInstanceTimeVarying';
                
                         //does not have to be a time varying, could be any kind of material interface
                	MITV_Decal.SetParent( MaterialInstanceTimeVarying'yourMITV' );
                
                	WorldInfo.MyDecalManager.SpawnDecal( 
                		MITV_Decal, 
                		hitLoc,//Location, 
                		rot(-16384,0,0), 
                		randRange(384,512),//ImpactEffect.DecalWidth,
                		randRange(384,512),//ImpactEffect.DecalHeight, 
                		1000.0, 
                		false,
                		RandRange(0, 360)
                	);
                	
                        //material instance time varying specific
                	MITV_Decal.SetScalarStartTime( 
                		'DissolveAmount', 
                		RandRange(7, 12) 
                	);
                }
                enjoooy

                Comment


                  #23
                  Originally posted by Ouroboross View Post
                  Code:
                  class UDNProj_Champi_Platform extends UTProjectile;
                  
                  simulated function PostBeginPlay()
                  {
                  	Super.PostBeginPlay();
                  	//SetTimer(10);                  //Grenade begins unarmed
                  	RandSpin(100000);
                  }
                  
                  
                  /*
                  simulated event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
                  {
                  	local rotator myRot;
                      SetPhysics(PHYS_None);
                  
                      MomentumTransfer = 50000;
                  
                      if ( Champi(Other) == none || Debris(Other) == none )
                  	{
                                  if (HitNormal.Z < -0.3)
                                  {
                                          //Will Explode
                                  }
                  
                                  else if (HitNormal.X < -0.5)
                                  {
                                          //Will Explode
                                  }
                  
                                  else if (HitNormal.X > 0.5)
                                  {
                                          //Will Explode
                                  }				
                  				
                                  else if (HitNormal.Z < 0.5)
                  				{
                                          myRot = rotator(HitNormal);
                  						myRot.Pitch -= 16384;
                  						SetRotation(myRot);
                                          SpawnChampi_Wall(Other, vect(0,0,0));
                                  }
                  
                                  else if (HitNormal.X < 0.5)
                  				{
                                          //myRot.Pitch = (HitNormal.X * 32768/PI *-0.5);
                                          SetRotation(rotator(HitNormal));
                                          SpawnChampi_Ground(Other, vect(0,0,0));
                  				}
                  
                                  else if ( Champi(Other) != none || Debris(Other) == none)
                  		{
                                          //Will Explode
                  		}
                  	}
                  
                          Explode(Location, vect(0,0,1));
                  }
                  */
                  
                  
                  simulated event HitWall(vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
                  {
                  	local rotator myRot;
                      SetPhysics(PHYS_None);
                  
                      MomentumTransfer = 50000;
                  
                      if (HitNormal.Z < -0.5)
                      {
                              //Will Explode
                      }
                  
                  	else if (HitNormal.Z < 0.75)
                  	{
                  			myRot = rotator(HitNormal);
                  			myRot.Pitch /= 3;
                                          SetRotation(myRot);
                  			SpawnChampi_Wall(Wall, vect(0,0,0));
                  	}
                  
                      else if (HitNormal.X < -0.5)
                      {
                              //Will Explode
                      }
                  
                      else if (HitNormal.X > 0.5)
                      {
                              //Will Explode
                      }
                  
                  	
                      else if (HitNormal.X < 0.5)
                  	{
                                  if (HitNormal.X < 0)
                                  {
                  						myRot = rotator(-HitNormal);
                                          myRot.Pitch += 16384;
                                  }
                  
                  				else if (HitNormal.X >= 0)
                                  {
                                          myRot = rotator(HitNormal);
                  						myRot.Pitch -= 16384;
                                  }
                  
                  	SetRotation(myRot);
                  	SpawnChampi_Ground(Wall, vect(0,0,0));
                      }
                  
                  	else
                  	{
                  			//will explode
                  	}
                  
                  	self.Destroy();
                  	//Explode(Location, vect(0,0,1));
                  }
                  
                  
                  simulated function SpawnChampi_Wall(Actor Wall, vector HitNormal)
                  {
                  	local Actor Champi_Wall;
                  
                          Champi_Wall = Spawn(class'UDNChampi_Platform_Wall');
                          Champi_Wall.SetBase(Wall);
                  }
                  
                  
                  simulated function SpawnChampi_Ground(Actor Wall, vector HitNormal)
                  {
                  	local Actor Champi_Ground;
                  
                          Champi_Ground = Spawn(class'UDNChampi_Platform_Ground');
                          Champi_Ground.SetBase(Wall);
                  }
                  
                  
                  
                  /*	bBlockedByInstigator = true;
                  
                  	if ( WorldInfo.NetMode != NM_DedicatedServer )
                  	{
                  		PlaySound(ImpactSound, true);
                  	}
                  
                  	// check to make sure we didn't hit a pawn
                  
                  	if ( Pawn(Wall) == none )
                  	{
                  		Velocity = 0.75*(( Velocity dot HitNormal ) * HitNormal * -2.0 + Velocity);   // Reflect off Wall w/damping
                  		Speed = VSize(Velocity);
                  
                  		if (Velocity.Z > 400)
                  		{
                  			Velocity.Z = 0.5 * (400 + Velocity.Z);
                  		}
                  		// If we hit a pawn or we are moving too slowly, explod
                  
                  		if ( Speed < 20 || Pawn(Wall) != none )
                  		{
                  			ImpactedActor = Wall;
                  			SetPhysics(PHYS_None);
                  		}
                  	}
                  	else if ( Wall != Instigator ) 	// Hit a different pawn, just explode
                  	{
                  		Explode(Location, HitNormal);
                  	}
                  */
                  
                  
                  simulated function PhysicsVolumeChange( PhysicsVolume NewVolume )
                  {
                  	if ( WaterVolume(NewVolume) != none )
                  	{
                  		self.Destroy();
                                  //Explode(Location, vect(0,0,1));
                  	}
                  
                  	Super.PhysicsVolumeChange(NewVolume);
                  }
                  
                  
                  DefaultProperties
                  {
                      ProjFlightTemplate=ParticleSystem'WP_RocketLauncher.Effects.P_WP_RocketLauncher_Smoke_Trail'
                  
                      ProjExplosionTemplate=ParticleSystem'WP_RocketLauncher.Effects.P_WP_RocketLauncher_RocketExplosion'
                      ExplosionLightClass=class'UTGame.UTRocketExplosionLight'
                  
                  
                      Speed=500.0
                      MaxSpeed=500.0
                      Damage=26.0
                      DamageRadius=220.0
                      MomentumTransfer=50000
                      MyDamageType=class'UTDmgType_Grenade'
                      LifeSpan=3.0
                      ExplosionSound=SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_Impact_Cue'
                      ExplosionDecal=MaterialInstanceTimeVarying'WP_RocketLauncher.Decals.MITV_WP_RocketLauncher_Impact_Decal01'
                      DecalWidth=128.0
                      DecalHeight=128.0
                      bCollideWorld=true
                      bBounce=false
                      TossZ=+10.0
                      Physics=PHYS_Falling
                      CheckRadius=36.0
                  
                      ImpactSound=SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_GrenadeFloor_Cue'
                  
                      bNetTemporary=False
                      bWaitForEffects=false
                  
                  
                      CustomGravityScaling=0.5
                  }
                  I didn't modify anything over UTProjectile

                  to reference your projectile you can

                  1. obtain a variable for the projectile when it spawns, look through your UTweapon code to see where projectile is spawning

                  2. pass back a reference to the parent weapon in postbegin play of the projectile

                  3. look through your utweapons ProjectileFire() function to see where your projectile spawned

                  make sure you use a global variable

                  Code:
                  //near top of class
                  var projectile ThisIsAGlobalVar;

                  Comment


                    #24
                    Okay I got it, I don't know if I'll have enough time to incorporate it and make it work since next week (finishing time of my game production), I'll tell you
                    Thanks enough for everything ! =)

                    Comment

                    Working...
                    X