Tegleg Records

Tegleg Records
Tegleg Records

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

3 comments:

  1. It dont work I get errors try ths code agai it will get the error Take Damage redefinition wrong.

    ReplyDelete
  2. ok they must have changed it...
    search in actor.uc for the TakeDamage function and copy the definition.
    ei
    function TakeDamage(blah..)

    ill do an update soon as the landscape is fixed in udk.

    ReplyDelete
  3. How do you enter the code in?
    I'm kind of new to UDK and have finished my first game, but need a menu.

    ReplyDelete

Loading...