Results 1 to 8 of 8

Thread: Possess Pawn: Possessing an another pawn in another place in the mapa. How?

  1. #1
    Humberto Milanez
    Guest

    Possess Pawn: Possessing an another pawn in another place in the mapa. How?

    Hi all.

    Above is my Question. For example when I touched a trigger I possess a pawn that it is in another place in the mapa. I get this possess pawn code (works fine) in the Tegleg's blog and how can I do it from this code?


    exec function FPress()
    {
    //declare the variables
    local pawn p;
    local vector l;
    local rotator r;

    //set the variables
    p = Pawn;
    l = Pawn.Location;
    r = Pawn.Rotation;

    // get rid of the old pawn
    UnPossess();
    p.Destroy();

    //spawn a new pawn and possess it
    p = Spawn(class'SomePawnClass', , ,l,r);

    //use false if you spawned a character and true for a vehicle
    Possess(p, false);
    }

    Thanks for your patience and sorry for I being a beginner.

  2. #2
    cozzbp
    Guest
    not sure if this helps, but I have an item in my game that when used, you possess the pawn you hit with the weapon. here is the Code for the traceswing function:

    Code:
    function TraceSwing()
    {
    
       local UTPawn V, Best, tempHolder;
    	
    	local vector ViewDir, PawnLoc2D, VLoc2D, ReachVector;
    	local float NewDot, BestDot;
    	local Actor HitActor;
    	local Vector HitLoc, HitNorm, SwordTip, SwordHilt, Momentum;
    	local int DamageAmount;
    	
    	tempHolder = UTPawn(OwnerPawn);
    	// Pick best nearby vehicle
    	PawnLoc2D = OwnerPawn.Location;
    	PawnLoc2D.Z = 0;
    	ViewDir = vector(OwnerPawn.Rotation);
    	ReachVector=ViewDir;
    	ReachVector.X=ReachVector.X+100;
    	//`Log("================CHECK RADIUS:" $Pawn.VehicleCheckRadius);
    	
    	ForEach OwnerPawn.OverlappingActors(class'UTPawn', V, 100,,true)
    	{
    		// Prefer pawns that Pawn is facing
    		VLoc2D = V.Location;
    		Vloc2D.Z = 0;
    		NewDot = Normal(VLoc2D-PawnLoc2D) Dot ViewDir;
    		//`Log("================FOUND:" $V.Name);
    		if ( NewDot>0.8)
    		{
    			// check that pawn is visible
    			if ( FastTrace(V.Location,OwnerPawn.Location) )
    			{
    				//Best = V;
    				
    				BestDot = NewDot;
    				
    				
    				if(V != None && V.Controller != None)
    				{
    					
    					//Pawn(V).Controller.Unpossess();
    					//Pawn(V).SetOwner(V);
    					
    					
    					OwnerPawn.Controller.Possess(V,false);
    				}
    		
    			}
    		}
    	}

  3. #3
    cozzbp
    Guest
    not sure if this helps, but I have an item in my game that when used, you possess the pawn you hit with the weapon. here is the Code for the traceswing function:

    Code:
    function TraceSwing()
    {
    
       local UTPawn V, Best, tempHolder;
    	
    	local vector ViewDir, PawnLoc2D, VLoc2D, ReachVector;
    	local float NewDot, BestDot;
    	local Actor HitActor;
    	local Vector HitLoc, HitNorm, SwordTip, SwordHilt, Momentum;
    	local int DamageAmount;
    	
    	tempHolder = UTPawn(OwnerPawn);
    	// Pick best nearby vehicle
    	PawnLoc2D = OwnerPawn.Location;
    	PawnLoc2D.Z = 0;
    	ViewDir = vector(OwnerPawn.Rotation);
    	ReachVector=ViewDir;
    	ReachVector.X=ReachVector.X+100;
    	//`Log("================CHECK RADIUS:" $Pawn.VehicleCheckRadius);
    	
    	ForEach OwnerPawn.OverlappingActors(class'UTPawn', V, 100,,true)
    	{
    		// Prefer pawns that Pawn is facing
    		VLoc2D = V.Location;
    		Vloc2D.Z = 0;
    		NewDot = Normal(VLoc2D-PawnLoc2D) Dot ViewDir;
    		//`Log("================FOUND:" $V.Name);
    		if ( NewDot>0.8)
    		{
    			// check that pawn is visible
    			if ( FastTrace(V.Location,OwnerPawn.Location) )
    			{
    				//Best = V;
    				
    				BestDot = NewDot;
    				
    				
    				if(V != None && V.Controller != None)
    				{
    					
    					//Pawn(V).Controller.Unpossess();
    					//Pawn(V).SetOwner(V);
    					
    					
    					OwnerPawn.Controller.Possess(V,false);
    				}
    		
    			}
    		}
    	}

  4. #4
    Humberto Milanez
    Guest
    Ok, cozzbp.

    I will test it and thank you.

  5. #5
    Calneon
    Guest
    Quote Originally Posted by Humberto Milanez View Post
    Hi all.

    Above is my Question. For example when I touched a trigger I possess a pawn that it is in another place in the mapa. I get this possess pawn code (works fine) in the Tegleg's blog and how can I do it from this code?


    exec function FPress()
    {
    //declare the variables
    local pawn p;
    local vector l;
    local rotator r;

    //set the variables
    p = Pawn;
    l = Pawn.Location;
    r = Pawn.Rotation;

    // get rid of the old pawn
    UnPossess();
    p.Destroy();

    //spawn a new pawn and possess it
    p = Spawn(class'SomePawnClass', , ,l,r);

    //use false if you spawned a character and true for a vehicle
    Possess(p, false);
    }

    Thanks for your patience and sorry for I being a beginner.
    I don't understand the question, you say the code works fine so what's the problem?

    EDIT: If I understand correctly you just want to change 'l' and 'r' variables to the new pawn's location and rotation?

  6. #6
    Humberto Milanez
    Guest
    Quote Originally Posted by Calneon View Post
    I don't understand the question, you say the code works fine so what's the problem?

    EDIT: If I understand correctly you just want to change 'l' and 'r' variables to the new pawn's location and rotation?
    Hmmm...

    I think that is ti. I will test it.


    Thank you.

  7. #7
    Humberto Milanez
    Guest
    Hi, Calneon.

    I used this code but not works:
    Code:
    exec function FPress()
    {
    //declare the variables
    local pawn p;
    local vector l;
    local rotator r;
    
    local PowerPawn UT;
    
    //set the variables
    p = pawn;
    UT = PowerPawn(Pawn);
    l = UT.Location;
    r = UT.Rotation;
    
    // get rid of the old pawn
    UnPossess();
    p.Destroy();
    
    //spawn a new pawn and possess it
    ConsoleCommand("ChangeTeam Blue");
    
    p = Spawn(class'TestePawn', , ,l,r);
    
    //use false if you spawned a character and true for a vehicle
    Possess(p, false);
    }

  8. #8
    cozzbp
    Guest
    Make sure that you are calling it from the right place. The code he gave you would need to be called from your pawn's controller class. If you needed to call it from the Pawn class itself use this code:

    Code:
    Controller.Possess(OtherPawn,false);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •