Tegleg Records

Tegleg Records
Tegleg Records

Friday, 2 September 2011

How to make a City for UDK with Urban Pad

follow these steps to easily create a city for UDK using Urban Pad

open urban pad

1. open project on hard disk and navigate to simple city beginner, should be in documents/gamr7....
2. click city, double click simple city beginner


3. click the last node and wait for it to build

when its finished building your city should look something like this


4. click export and use these settings




udk

1. import
2. double click each mesh and change its collision like this


3. drag all meshs into the 3d viewport
4. right click a mesh, select - all static mesh actors
5. press f4 to bring up the properties, click Movevment - Location and type 0 into x, y and z.



save your map

done!

you might want to add some materials and a sky
Have fun razzing round your new city


Sunday, 5 June 2011

UDK Mouse Robot Style AI

a very basic mouse style ai.
it navigates its way round a map without using pathnodes or navmesh.
it traces directly in front to see if theres anything in the way, if theres nothing it moves forward.
if theres an obstruction in front, it takes a random distance left or right and does another trace. if theres an obstruction it does it again, if not it moves there.

heres a vid

heres the code
class AIMouse extends GameAIController;

var Vector MyTarget;
var vector InFront;
var vector X,Y,Z;
var vector HitLoc, HitNormal;
var Actor HitActor;

simulated event PostBeginPlay()
{
 super.PostBeginPlay();

        //start the brain going at 1 second intervals
   SetTimer(1.0, true, 'BrainTimer');
}

function BrainTimer()
{
  GetAxes(Pawn.Rotation, X,Y,Z);

  InFront = Pawn.Location + 200 * X;

  //trace in front
  HitActor = Trace(HitLoc, HitNormal, InFront, Pawn.Location);
  //DrawDebugSphere( HitLoc, 30, 10, 0, 255, 0 );

  if (HitActor != None) //theres something in front
  {
  //trace randomly left or right
     TraceRandom();

  }
  else  //theres nothing in front
  {
  //move forward
    MyTarget = InFront;
    GoToState('MoveAbout');
  }

}

function TraceRandom()
{
  local int LeftRight;

  //make a random number
  LeftRight = Rand(200) - Rand(200);

  GetAxes(Pawn.Rotation, X,Y,Z);

  InFront = Pawn.Location + LeftRight * Y;

     //do another trace to a random location left or right
     HitActor = Trace(HitLoc, HitNormal, InFront, Pawn.Location);
     DrawDebugSphere( HitLoc, 30, 10, 255, 0, 0 );

     if (HitActor != None)  //if we trace something
     {
        Return;
     }
     else  //if we trace nothing
     {
     //move there
        MyTarget = InFront;
    GoToState('MoveAbout');
     }
}

state MoveAbout
{
Begin:

    MoveTo(MyTarget);
}

defaultproperties
{

}

Friday, 3 June 2011

udk ai, random movement, follow player

heres a udk ai that moves around randomly unless the player is close, then it will follow.

class AIRandom2 extends GameAIController;

//declaring variables here means
//they may be used throughout this script
var Vector MyTarget;

//at the start of the level
simulated event PostBeginPlay()
{
super.PostBeginPlay();

//start the brain going at half second intervals
SetTimer(0.5, true, 'BrainTimer');
}

function BrainTimer()
{
//local variables are only used in this function
local Pawn P;
local float Distance;

//check if theres another pawn, the pawn belongning to this controller isnt counted
foreach WorldInfo.AllPawns(class'Pawn', P)
{
if (P != None)  //if there is one
{

//get the distance
Distance = VSize2D(Pawn.Location - P.Location);

//if its closer than 500
if (Distance <= 500)
            {
             //make its location MyTarget
             MyTarget = P.Location;
             //so it doesnt fly up n down
             MyTarget.Z = P.Location.Z;
             //MoveTo the pawn
             GoToState('MoveAbout');
            }
            else  //if its too far away
            {
            //do whats in the function called MoveRandom()
            MoveRandom();
            }

          }
          else  //if there isnt another pawn
          {
            //call the function MoveRandom()
            MoveRandom();
          }
        }
}

function MoveRandom()
{   
 local int OffsetX;
  local int OffsetY;

  //make a random number
  OffsetX = Rand(500)-Rand(500);
  OffsetY = Rand(500)-Rand(500);

       //some distance left or right and some distance in front or behind
    MyTarget.X = Pawn.Location.X + OffsetX;
    MyTarget.Y = Pawn.Location.Y + OffsetY;
       //so it doesnt fly up n down
       MyTarget.Z = Pawn.Location.Z;

    //move to the random location
    GoToState('MoveAbout');
}

state MoveAbout
{
Begin:
    //MoveTo makes it move to a location (vector)
    MoveTo(MyTarget);
}

defaultproperties
{

}

udk random movement ai code

heres an ai that moves around randomly

class RandomAI extends GameAIController;

var Vector MyTarget;

simulated event PostBeginPlay()
{
super.PostBeginPlay();

//start the brain going at half second intervals
SetTimer(0.5, true, 'BrainTimer');
}

function BrainTimer()
{
local int OffsetX;
local int OffsetY;

//make a random offset, some distance away
OffsetX = Rand(500)-Rand(500);
OffsetY = Rand(500)-Rand(500);

//some distance left or right and some distance in front or behind
MyTarget.X = Pawn.Location.X + OffsetX;
MyTarget.Y = Pawn.Location.Y + OffsetY;
//so it doesnt fly up n down
MyTarget.Z = Pawn.Location.Z;

GoToState('MoveAbout');

}

state MoveAbout
{
Begin:

MoveTo(MyTarget);
}

defaultproperties
{

}

Thursday, 24 March 2011

UDK Real 3D Menu Without Scaleform

Heres this then.
A menu made from in game 3D models.


The code below is for 2 types of 'button'.
1. TegButton_Actor.uc - this one has an OK button
2. TegButton_Ok - this is the ok button. can be used if you dont need an ok.

just change the StaticMesh in DefaultProperties to use your own.

Vid Here

class TegButton_Actor extends Actor
    placeable;

var() const editconst LightEnvironmentComponent LightEnvironment;
var() string Command;

auto state MenuActive
{
    event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
    local TegButton_Ok OkButon;
    local vector L;

 super.TakeDamage(DamageAmount,EventInstigator, HitLocation,Momentum,DamageType,HitInfo,DamageCauser);

    L=Location;
    L.Z=Location.Z + 100;

    //when taking damage, spawn an ok button and give it a console command
    OkButon = Spawn(class'TegButton_Ok',,,L, Rotation);
 OkButon.Command = Command;
    }

}

DefaultProperties
{
    Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
 bEnabled=TRUE
    End Object
    LightEnvironment=MyLightEnvironment
    Components.Add(MyLightEnvironment)

    begin object class=StaticMeshComponent Name=BaseMesh

        // change this staticmesh to your own 'button' model
 StaticMesh=StaticMesh'EngineMeshes.Cube'

 //LightEnvironment=MyLightEnvironment
    end object
    Components.Add(BaseMesh)

    CollisionComponent=BaseMesh
    bCollideActors=true
    bBlockActors=true

    //default console command
    Command="quit"

}

class TegButton_Ok extends Actor
    placeable;

var() const editconst LightEnvironmentComponent LightEnvironment;
var() string Command;


auto state MenuActive
{
    event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
    local PlayerController PC;

 super.TakeDamage(DamageAmount,EventInstigator, HitLocation,Momentum,DamageType,HitInfo,DamageCauser);

    //on TakeDamage tell all the players the console command
 foreach WorldInfo.AllControllers(class'PlayerController', PC)
  {
   PC.ConsoleCommand(Command);
  }
    }

}

DefaultProperties
{
    Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
 bEnabled=TRUE
    End Object
    LightEnvironment=MyLightEnvironment
    Components.Add(MyLightEnvironment)

    begin object class=StaticMeshComponent Name=BaseMesh
 StaticMesh=StaticMesh'EngineMeshes.Cube'
 //LightEnvironment=MyLightEnvironment
    end object
    Components.Add(BaseMesh)

    CollisionComponent=BaseMesh
    bCollideActors=true
    bBlockActors=true

}
based on Mougli's SandboxSpinningBox

UDK Mobile Plug & Play Car

Name: VHm_Escort
Type: Package and scripts
Category: Vehicles
UDK version: March. 2011 (Mobile) and newer
Author: Tegleg Records
Many thanks to: moot
Model comes from Google Warehouse

Download Here

UDK Plug & Play Car with Weapon

heres a big vehicle for you to play with. For NOVEMBER UDK and newer.



contains Original Version and LookSteer Version
Download Here

it has:
* rotating turret that fires the manta weapon.
* 6 camera modes, with rear view function. Static cam when first enter vehicle.
* nicely ballanced with slippery tyres for drifting
* its fast

comes with the 3ds max model file so you can make your own vehicle. the model is a terrible 'placeholder', im no modeler :s
open it up in max, delete the mesh, add your own, skin the bones. (look for geodav tutorials if you dont know what im talking about)

HOW TO INSTALL:

place the files from the zip in your udk instalation folder.
the zip is arranged in folders to make it easy for you.

Development/Src/UTGame/Classes - Script Files.
Development/Src/UTGameContant/Classes - More Script Files. (wont work for udk versions older than august)

UDKGame/Content/Vehicles - the vehicle package (wont work for udk versions older than november)

Important:
add these lines to DefaultInput.ini for the camera control.
add to the bottom of ; Primary default bindings section
UDKGame/Config/DefaultInput.ini

.Bindings=(Name="R",Command="GBA_LookBack | OnRelease GBA_NotLookBack")
.Bindings=(Name="V",Command="GBA_Camchange")

Dynamicaly changing the Player Pawn

How to Dynamicaly change the Player Pawn.
Put this in your Player Controller. The example here is using an 'exec' function so it can be triggered from a button press or console command.


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);
}

UDK Easy Save System

How to save a variable in UDK unreal script.

class Something extends SomethingElse
config(SomeIni); //this points to an ini file where stuff is saved, in this case UDKSomeIni.ini

var config int SomeVar; // putting config allows you to save the variable

//your function where you set and save the variable
function SomeFunction()
{
SomeVar = 20; //give it a value

//SaveConfig() will save whatever variables have config
// it will create UDKSomeIni.ini (if it doesnt exist) and save the variable
SaveConfig();
}


Loading...