Results 1 to 4 of 4
  1. #1
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    187

    Default Another question on rotating bones programmatically

    Hi again,

    I have a security camera model that must look at the player. This camera mesh has two connected bones, one at the root, and one along the direction the lens is facing.
    I simply want to rotate the lens bone to look at the player pawn. So I added a SkelControlSingleBone to the animtree as shown in this screenshot . My simple code is as follows:

    Code:
    //Gets called every tick to update the camera rotation to look at the player pawn
    simulated function RotateCamManually()
    {
            local Rotator DirToPawn; 
    
            SkelMeshComp.GetSocketWorldLocationAndRotation('CameraSocket', CameraBoneLocation, , );	 
    	DirToPawn=Rotator(PWNPawn(PWNPlayerController(GetALocalPlayerController()).Pawn).Location - CameraBoneLocation);
    	ASkelControl.BoneRotation.Yaw=DirToPawn.Yaw;
    
    }
    where
    SkelMeshComp is the skeletal mesh,
    CameraBoneLocation is the world location of a socket on the Camera lens bone,
    and ASkelControl is the skeletal controller

    The bone rotates fine, but I cannot get it to look directly at the player. It is always perpendicular (looking towards the right) of the player.
    I've tried so many things but cannot seem to get it right. Any help would be much appreciated as usual.

    Cheers.

  2. #2
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Posts
    187

    Default

    I've hacked a fix for now.

    Seems like the rotation is offset by exactly 90 degrees, so just changed
    "ASkelControl.BoneRotation.Yaw=DirToPawn.Yaw;"
    to
    "ASkelControl.BoneRotation.Yaw=DirToPawn.Yaw + 90.0f * DegToUnrRot;"

  3. #3
    Redeemer
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    1,226

    Default

    The cameras bone is probably rotated in the wrong way. Needs to be fixed in your model.
    2B || !(2B)

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

    Default

    Yes, the skeleton orientation needs to be chosen carefully. I'm currently working with one where I have things like pitch = -yaw which can be difficult to work with. UDK expects the model to be facing along the +x axis.

    Also I'm not sure about the camera, but when dealing with actors I ended up having to rotate into the local transform:
    Code:
    TargetRotation = Rotator((EnemyTarget.Location - MyLocation) << Rotation);
    I also have my rotations in the mesh settings set to BCS_BoneSpace.
    Last edited by paco; 03-07-2012 at 04:06 PM.


 

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.