Page 9 of 9 FirstFirst ... 789
Results 321 to 332 of 332

Thread: UDK Gems

  1. #321
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Posts
    213

    Default

    Hi. I have a question about Platformer Kit Gem.
    When turns, player pawn is rotates back to the camera.


    But I want that it look at a camera. I found functions UpdateRotation, FacingRotation and tried to invert it's parameters, but there is no such effect. How would I achieve this?

  2. #322
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Posts
    213

    Default

    silence...

  3. #323
    MSgt. Shooter Person
    Join Date
    Feb 2012
    Location
    Bulgaria, Sofia
    Posts
    122

    Default

    Your pawn, when changing direction is rotating by +180 to the right and by -180 degrees to the left. If you want to make it rotate on the camera side, just reverse the rotation.
    When you do so, your pawn will rotate by +180 to the left and by -180 to the right.

    I don't remember where the function is exactly, you should look at the PlayerMove function and see what happens while the player is moving. The rotation angle is measured on a per-frame basis, so if you check what the PlayerMove function is doing you should be able to see the initial and desired rotation angles. If you reverse the desired rotation angle you will get what you want.
    Last edited by Dragon666; 11-20-2012 at 11:00 AM.
    In darkness born, to light devoted.
    Code:
    /** What the f*ck per minute - KPI for source readability,  How the hell per second - KPI for code functionality */ 
    var int _iWtfPMin, _iHthPSec;
    if( _iWtfPMin > _iHthPSec ) { Developer(CodeOwner).SetOnFire( Napalm, noDelay ); }

  4. #324
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Posts
    213

    Default

    yeah, i tried set
    DeltaRot = -DesiredRotation;
    but, Error, Types are incompatible with '-'
    so?

  5. #325
    MSgt. Shooter Person
    Join Date
    Feb 2012
    Location
    Bulgaria, Sofia
    Posts
    122

    Default

    Don't set the raw rotator. Just set the desired rotation to it's negative.
    Desiredrotation *= -1

    If the desiredrotation is a rotator, just set the appropriate vector in it, desiredrot.yaw for example.
    In any case if you are going to mess with rotations you need to use (and understand) vectors.

    I could check the code and post the solution here, but it would be better if you made it yourself. This is not the only change you will try to implement and it is simple enough to be used as an excersise.
    In darkness born, to light devoted.
    Code:
    /** What the f*ck per minute - KPI for source readability,  How the hell per second - KPI for code functionality */ 
    var int _iWtfPMin, _iHthPSec;
    if( _iWtfPMin > _iHthPSec ) { Developer(CodeOwner).SetOnFire( Napalm, noDelay ); }

  6. #326
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Posts
    213

    Default

    ok, thank you. I will try.

  7. #327
    MSgt. Shooter Person
    Join Date
    Feb 2012
    Location
    Bulgaria, Sofia
    Posts
    122

    Post

    A simple explanation.
    I hope it will bring some clearance on the topic of rotation transitions.
    Probably this is not the right place for this, so I apologize if that is the case.

    How UDK works:
    The underlying engine makes all the calculations necessary to output the proper graphics at decent frame rate.
    Thus if you want to modify geometry or transformations at run time the best way to do it is to set the start and end points of a transformation and let the engine handle it.
    This is in general how things are done in UDK and UnrealScript.

    Setting Pawn rotation in the Platformer Gem:
    The rotation of the pawn is controlled by the "strafe" input and the camera/mouse vertical movement.
    In class "SPG_PlayerController" in function "PlayerWalking^PlayerMove" (the function PlayerMove is in state PlayerWalking) the player acceleration(movement and speed of the player) is set according to the playerinput strafe value.
    As such, on a platformer on the PC it has 2 possible values (+90 degrees, -90 degrees).
    The resulting vector is after that applied also on the rotation of the Pawn (switching to function "UpdateRotation").

    In "UpdateRotation" the vertical offset of the weapon is calculated by the camera/mouse vertical offset : DeltaRot.Pitch = PlayerInput.aLookUp;).
    Then the Pawn "FaceRotation" is called. As we have a custom PlayerPawn class it's function is used instead of the general Pawn function (SPG_PlayerPawn.FaceRotation).

    This is the spot we need to look in in order to change the way the Pawn rotates.
    The code below calculates a smooth transition between angles (percentage value between start and end based on a step).
    Code:
    Lerp(CurrentYaw, DesiredYaw, TurnRate * DeltaTime);
    So we're calculating the next percentage angle from our current Yaw towards desired Yaw based on the turn speed(TurnRate) and the time since the last frame (DeltaTime).

    Here is the "magic" trick.
    A few lines above we can see
    Code:
    DesiredYaw = NewRotation.Yaw;
    Now, we know that our "Yaw" comes from the strafe input so when we move to the right it's +90 degrees (which is 16384 in UDK degrees). When we rotate to the left it's -() degrees ( -16384 ).
    So the Lerp function calculates from -16384 to 16384 when we rotate right, and from 16384 to -16384 when we rotate left.
    Knowing this the rotation angles are always from -16384 to 16384 (which is facing away from the camera).
    To change the rotation so that the Pawn does it facing TOWARDS the camera we need to make all rotation values to be between +90 degrees to +270 degrees.
    So we just add the folowing in "FaceRotation" function of our "SPG_PlayerPawn", right after the line "DesiredYaw = NewRotation.Yaw;"
    Code:
    if(NewRotation.Yaw < 0)
    {
    	// increase the desider angle by 360 degrees thus turning the rotation to the opposite direction
    	DesiredYaw += 65536;
    }

    Resulting code (SPG_PlayerPawn.FaceRotation):
    Code:
    simulated function FaceRotation(Rotator NewRotation, float DeltaTime)
    {
    	local Rotator FacingRotation;
    
    	// Set the desired yaw the new rotation yaw
    	if (NewRotation.Yaw != 0)
    	{
    		DesiredYaw = NewRotation.Yaw;
    		if(NewRotation.Yaw < 0)
    		{
    			// increase the desider angle by 360 degrees thus turning the rotation to the opposite direction
    			DesiredYaw += 65536;
    		}
    	}
    	// If the current yaw doesn't match the desired yaw, then interpolate towards it
    	if (CurrentYaw != DesiredYaw)
    	{
    		CurrentYaw = Lerp(CurrentYaw, DesiredYaw, TurnRate * DeltaTime);
    	}
    
    	// If we have a valid aim offset node
    	if (AimNode != None)
    	{
    		// Clamp the current pitch to the view pitch min and view pitch max
    		CurrentPitch = Clamp(CurrentPitch + NewRotation.Pitch, ViewPitchMin, ViewPitchMax);
    
    		if (CurrentPitch > 0.f)
    		{
    			// Handle when we're aiming up
    			AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMax;
    		}
    		else if (CurrentPitch < 0.f)
    		{
    			// Handle when we're aiming down
    			AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMin;
    			
    			if (AimNode.Aim.Y > 0.f)
    			{
    				AimNode.Aim.Y *= -1.f;
    			}
    		}
    		else
    		{
    			// Handle when we're aiming straight forward
    			AimNode.Aim.Y = 0.f;
    		}
    	}
    
    	// Update the facing rotation
    	FacingRotation.Pitch = 0;
    	FacingRotation.Yaw = CurrentYaw;
    	FacingRotation.Roll = 0;
    
    	SetRotation(FacingRotation);
    }
    Conclusion:
    When you want to change something follow these simple steps:
    • analyze how things currently work
    • search for something similar in the code-base to see if it's not already implemented
    • find a suitable solution that works "The UDK way" (changing start or end values, or change Boolean flags, or change states)
    • find the exact spot where you need to implement it (the exact function/property of the proper object)



    I hope this was helpful for those of us, that are new to intermediate in UDK coding and modifications.
    Last edited by Dragon666; 11-23-2012 at 05:46 AM.
    In darkness born, to light devoted.
    Code:
    /** What the f*ck per minute - KPI for source readability,  How the hell per second - KPI for code functionality */ 
    var int _iWtfPMin, _iHthPSec;
    if( _iWtfPMin > _iHthPSec ) { Developer(CodeOwner).SetOnFire( Napalm, noDelay ); }

  8. #328
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Posts
    213

    Default

    Oh... Thank you very very very much!
    I could not understand which function do it. Now, I know

  9. #329

    Default

    Hey, I found a problem with the MOBA starter kit, it seems that, when you die, at respawn you cannot use any spell

    Im using UDK 2012-05

    I need to know how to make enmey units invisible when they arent on shight range of an ali entity




    Thanks!
    Last edited by nesjett; 02-08-2013 at 03:52 PM.

  10. #330
    Skaarj
    Join Date
    Dec 2007
    Location
    India
    Posts
    5
    Gamer IDs

    Gamertag: Skyharbor

    Default

    Just downloaded the Racer Starter Kit, I want to stop the wobble which occurs as soon as the vehicle stops, please help..

  11. #331
    MSgt. Shooter Person
    Join Date
    Oct 2011
    Posts
    235

    Default

    Maybe this is obvious to some, maybe it is written somewhere obvious and I missed it. This is specifically about the starter kits, but also covers other gems as well. What happens when I use the code/content provided with these gems?

    Can I release a game's source if it is based on a starter kit?
    Can I start an open source project with a starter kit (something like the Canvas GUI project)?
    Can I use some parts of it on a commercial project?

    Those might seem obvious yes or no questions, but I haven't seen anywhere where they have been definitively answered as yes or no.
    Last edited by RNG; 02-22-2013 at 02:17 PM.

  12. #332
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,514

    Default

    Can I release a game's source if it is based on a starter kit?
    Yes, but if it involves money in any way then the UDK license applies.

    Can I start an open source project with a starter kit
    No. You cannot amend the license attached with the starter kits since they are under the UDK license. GPL and other copy left licenses are not compatible with UDK.

    Can I use some parts of it on a commercial project?
    Yes.


 
Page 9 of 9 FirstFirst ... 789

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.