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

