Results 1 to 7 of 7
  1. #1
    Palace Guard
    Join Date
    Feb 2010
    Location
    Tegleg Records
    Posts
    3,785
    Gamer IDs

    Gamertag: tegleg digital

    Default [Code] Aeroplane Man

    hello

    heres a very simple 'aeroplane' script.
    'D' and 'A' - Thrust
    Arrows or Mouse - Steer/Pitch



    Tegleg_PlaneController.uc
    Code:
    class Tegleg_PlaneController extends UTPlayerController;
    
    var float Thrust;
    var Rotator ViewRotation;
    
    simulated function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    
    	SetCameraMode('ThirdPerson');
    }
    
    state PlayerWalking
    {
    ignores SeePlayer, HearNoise, Bump;
    
    	function PlayerMove(float DeltaTime)
    	{
    		local vector X,Y,Z;
              //`Log("!!!controller state WALKING : playermove !!!!!!!!!!!!!!!!!!!!!!!!");
    		GetAxes(Rotation,X,Y,Z);
    
            //forward thrust
    		Pawn.Acceleration = Thrust*X;
    		Pawn.Acceleration = Pawn.AccelRate * Normal(Pawn.Acceleration);
    
    		// Update rotation.
    		UpdateRotation( DeltaTime );
    
    		if ( Role < ROLE_Authority ) // then save this move and replicate it
    			ReplicateMove(DeltaTime, Pawn.Acceleration, DCLICK_None, rot(0,0,0));
    		else
    			ProcessMove(DeltaTime, Pawn.Acceleration, DCLICK_None, rot(0,0,0));
    	}
    
    	event BeginState(Name PreviousStateName)
    	{
    		Pawn.SetPhysics(PHYS_Flying);
    	}
    }
    
    //flight code///////////////////////////
    function UpdateRotation( float DeltaTime )
    {
    	local Rotator TempRotationP, TempRotationRoll, TempWorldRotationRoll;
    
    	ViewRotation = Rotation;
    	if (Pawn != None)
    	{
    		Pawn.SetDesiredRotation(ViewRotation);
    	}
    
    	//forward thrust
    	if ((PlayerInput.aStrafe > 0) && (Thrust < 5000))
    	{Thrust += 50;}
    
    	if ((PlayerInput.aStrafe < 0) && (Thrust > 0))
    	{Thrust -= 50;}
    
    	/////// ROTATION ////////////////
    
        //Roll
    	if (PlayerInput.aTurn > 0)
    	{
        ViewRotation.Yaw += 100;
        TempWorldRotationRoll = WorldInfo.Rotation;
        TempWorldRotationRoll.Roll += 10000;
        TempRotationRoll = RInterpTo(Rotation, TempWorldRotationRoll, DeltaTime, 1.0);
        ViewRotation.Roll = TempRotationRoll.Roll;
        }
    
    	if (PlayerInput.aTurn < 0)
    	{
        ViewRotation.Yaw -= 100;
        TempWorldRotationRoll = WorldInfo.Rotation;
        TempWorldRotationRoll.Roll -= 10000;
        TempRotationRoll = RInterpTo(Rotation, TempWorldRotationRoll, DeltaTime, 1.0);
        ViewRotation.Roll = TempRotationRoll.Roll;
        }
    
    	 //level out roll when no turn input
    	 if (PlayerInput.aTurn == 0)
    	{
          if(ViewRotation.Roll != 0) ViewRotation.Roll = Lerp(ViewRotation.Roll, 0.0, 0.01);
        }
    
        //Pitch
        if (PlayerInput.aForward > 0 || PlayerInput.aLookUp < 0)
        {ViewRotation.Pitch -= 100;}
    
        if (PlayerInput.aForward < 0 || PlayerInput.aLookUp > 0)
        {ViewRotation.Pitch += 100;}
    
        //level out pitch when no pitch input
        if (PlayerInput.aForward == 0 && PlayerInput.aLookUp == 0)
        {
        TempRotationP = RInterpTo(Rotation, WorldInfo.Rotation, DeltaTime, 1.0);
        ViewRotation.Pitch = TempRotationP.Pitch;
        }
    	SetRotation(ViewRotation);
    
    	if (Pawn != None)
    	{
    		Pawn.FaceRotation(ViewRotation, DeltaTime);
    		Pawn.SetDesiredRotation(ViewRotation);
    		Pawn.Mesh.SetRBRotation(ViewRotation);
    	}
    }
    Tegleg_PlanePawn.uc
    Code:
    class Tegleg_PlanePawn extends UTPawn;
    
    simulated function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    
        StartFlying();
    
        if(Mesh.PhysicsAssetInstance != None)
    	{
    		// Now set up the physics based on what we are currently doing.
    		if(Physics != PHYS_Flying)
    		{
    			SetPhysics(PHYS_Flying);
    		}
    	}
    	SetThirdPersonCamera(True);
    }
    
    simulated function FaceRotation(rotator NewRotation, float DeltaTime)
    {
    		SetRotation(NewRotation);
    }
    
    simulated singular event Rotator GetBaseAimRotation()
    {
    
       Return Rotation;
    
    }
    
    function SetMovementPhysics()
    {
       if (Physics != PHYS_Flying)
    	{
    		SetPhysics(PHYS_Flying);
    	}
    }
    
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
        local vector X, Y, Z;
    
        GetAxes(Rotation, X, Y, Z);
    
            //set the cam location and rotation
    	out_CamLoc = Location - 200 * X;
    	out_CamRot = Rotation;
    
    	return true;
    }
    
    defaultproperties
    {
    	// Flags
    	bCanBeDamaged=true
    	bCanCrouch=false
    	bCanFly=true
    	bCanJump=false
    	bCanSwim=false
    	bCanTeleport=true
    	bCanWalk=false
    	bJumpCapable=false
    	bProjTarget=true
    	bSimulateGravity=false
    	bShouldBaseAtStartup=true
    
    	GroundSpeed=5000
    	AirSpeed=6000
    
    }
    heres a gametype that uses this pawn and controller
    TeglegGame_Plane.uc
    Code:
    class TeglegGame_Plane extends UTGame;
    
    static event class<GameInfo> SetGameType(string MapName, string Options, string Portal)
    {
    	return default.class;
    }
    
    defaultproperties
    {
    	PlayerControllerClass=class'Tegleg_PlaneController  '
    	DefaultPawnClass=class'Tegleg_PlanePawn'
    }
    Have Fun!

    there will be no updates or fixes, thats up to you.
    feel free to ask questions if theres something you dont understand.
    Last edited by tegleg; 06-28-2012 at 01:08 PM. Reason: added mouse controll
    Code:
    We.spazmodicaly.simulate.new.sound.with.technical.equipment.that.is.specificaly.manufactured.for.humans.to.communicate.in.outer.space.Tegleg.manipulates.time.and.space.to.create.new.experiences.to.generate.a.hardcore.database.generation.
    LOOK>> Please ask questions in the forum, NOT a private message <<LOOK
    tegleg.co.uk
    My Tutorials n Stuff
    Games: Tegs Playground - Unwheel2 - VCTF Game - Sponic Mesh 3D - Shh.. dont tell anyone about my android apps.
    will code for money

  2. #2
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,646
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    awesome, is good for a game where the player has the power to fly !!!! very good tuto tegleg !!!!
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  3. #3
    Redeemer
    Join Date
    Jul 2011
    Location
    London, UK
    Posts
    1,765

    Default

    You should have gotten more replies here, i guess you didn't because no one really checks the documentation section
    btw it's a nice thing you got here, thanks for posting it,

  4. #4
    MSgt. Shooter Person
    Join Date
    Jun 2012
    Posts
    68

    Default

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.

    why didn't i see this before.

  5. #5
    Skaarj
    Join Date
    Jul 2012
    Location
    Berlin
    Posts
    8

    Default

    Nice one brah and thanks for sharing!

  6. #6
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Raleigh, N.C.
    Posts
    274

    Default

    where would i put this code? im new at udk
    Skorge is my Canadian master

  7. #7
    Palace Guard
    Join Date
    Feb 2010
    Location
    Tegleg Records
    Posts
    3,785
    Gamer IDs

    Gamertag: tegleg digital
    Code:
    We.spazmodicaly.simulate.new.sound.with.technical.equipment.that.is.specificaly.manufactured.for.humans.to.communicate.in.outer.space.Tegleg.manipulates.time.and.space.to.create.new.experiences.to.generate.a.hardcore.database.generation.
    LOOK>> Please ask questions in the forum, NOT a private message <<LOOK
    tegleg.co.uk
    My Tutorials n Stuff
    Games: Tegs Playground - Unwheel2 - VCTF Game - Sponic Mesh 3D - Shh.. dont tell anyone about my android apps.
    will code for money


 

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.