Results 1 to 7 of 7
  1. #1
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    265

    Default Is the problem in the code or the pawn?

    Hi guys,

    I'm trying to get the player to face an enemy automatically.. This works:

    Code:
    function AutoTargeting()
    {
            //Trace information
            local   Actor     HitActor;
            local   vector    HitLocation;
            local   vector    HitNormal;
    
            //Position information
            local   vector    TraceDistance;
            local   vector    LookDistance;
            local   Pawn      Target;
            local   Rotator   ViewRotation;
            local   Vector    ViewLocation;
            local   Rotator   r;
    
    	GetPlayerViewPoint(ViewLocation, ViewRotation);
    
            LookDistance = vector(ViewRotation) * 650;
    	TraceDistance = ViewLocation + LookDistance;
    
            HitActor = Trace( HitLocation, HitNormal, TraceDistance, ViewLocation, true, vect(5,5,5) );
    
            if ( Pawn(HitActor) == none)
            {
                    Return;
            }
    
            if ( Pawn(HitActor) != none )
            {
                    Target = Pawn(HitActor);
            }
    
            r=Rotator(Target.Location-Pawn.Location);
    
            if ( Pawn(HitActor) != none)
            {
                    SetRotation(r);
            }
            //ClientSetRotation(r);
    }
    The problem is when I am targeting monsters with different heights. If I make something small the player wont face down at all, he will look straight forward. I've tried changing the collision cylinder and that didn't help. Can anyone tell me whether this is a fault with the code or with the Pawn itself?

    Thanks!

  2. #2
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    There is a difference between where the pawn is rotated to face, and where the pawn is aiming. Have a look at the 'Focus' variable in the Controller class.

  3. #3
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    265

    Default

    Hi,

    Thanks for replying. This is in the PlayerController class. Not the AIController class. So 'Focus' does not matter. It is facing the right direction. With normal height monsters it's fine.. With short ones though it just looks straight forwards... I'm trying to figure out if this is because i'm not calling out the rotation right in the code or if I'm missing something on the pawn.

    I've checked the collision cylinder, that bits okay I think. But the functions just not centering the smaller enemy pawns correctly...


    Can anyone please help?

  4. #4
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    265

    Default

    Quote Originally Posted by Niandi View Post
    Hi,

    Thanks for replying. This is in the PlayerController class. Not the AIController class. So 'Focus' does not matter. It is facing the right direction. With normal height monsters it's fine.. With short ones though it just looks straight forwards... I'm trying to figure out if this is because i'm not calling out the rotation right in the code or if I'm missing something on the pawn.

    I've checked the collision cylinder, that bits okay I think. But the functions just not centering the smaller enemy pawns correctly...


    Can anyone please help?
    Bumped! Any ideas?

  5. #5
    Iron Guard
    Join Date
    Jan 2009
    Posts
    744

    Default

    Humanoid pawns discard pitch/roll iirc when being rotated, at least while in phys_walking. I'd rotate the pawn like you are, but also the playercontroller itself. I *think* that should in turn rotate the camera, which will them make your pawn's animtree aim direction blend kick in, making him look up/down

  6. #6
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    265

    Default

    Quote Originally Posted by Jetfire View Post
    Humanoid pawns discard pitch/roll iirc when being rotated, at least while in phys_walking. I'd rotate the pawn like you are, but also the playercontroller itself. I *think* that should in turn rotate the camera, which will them make your pawn's animtree aim direction blend kick in, making him look up/down
    Hi Jetfire, thanks for the help.. This is actually in my playercontroller code though, not in my custom pawn class.. Was that what you're referring to?

  7. #7
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Location
    Holly Springs, MS
    Posts
    332

    Default

    Im trying to figure out how to do exactly the same thing, get a pawn to rotate to face another pawn. So far I haven't been able to figure it out.
    Fortis Rex Rise Of The King, A Medieval Army-Commanding RPG: http://forums.epicgames.com/threads/...7#post29971877


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.