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, classDamageType, 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, classbased on Mougli's SandboxSpinningBoxDamageType, 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 }
It dont work I get errors try ths code agai it will get the error Take Damage redefinition wrong.
ReplyDeleteok they must have changed it...
ReplyDeletesearch 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.
How do you enter the code in?
ReplyDeleteI'm kind of new to UDK and have finished my first game, but need a menu.