Sunday, January 13, 2013

Update On The Menus

After looking through a mess of tutorials and forum posts I finally got my points pickup to work with my GFxMoviePlayer class for the upgrade screen. I ended up having to restructure how I was handling my points. I had originally had them declared and stored in that GFxMoviePlayer class, but I found that storing them in my Pawn class ended up being more accessible to a variety of classes when trying to adjust them. Since I could fully test the upgrade screen, since I could adjust how many points I could pick up, I was able to find a couple bugs in the system. I was able to fix all but one, and I haven't had a chance to troubleshoot the remaining one more to figure out why it's not working correctly.

If you are interested here is my code for the pickup. Not much there but this seemed to be the only way that worked for me getting the Pawn:

class PointPickup extends Actor placeable ClassGroup(GenericMenus, Placeables) HideCategories(Advanced, Movement, Display, Attachment, Collision, Physics, Debug, Mobile); var(Points) int Points; var GenericPC GPC; var GenericPawn GP; event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal) { GPC = GenericPC(GetALocalPlayerController()); GP = GenericPawn(GPC.Pawn); GP.PlayerPoints += Points; Destroy(); } defaultproperties { Points = 100 bCollideActors = true Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment bEnabled=true End Object Components.Add(MyLightEnvironment) Begin Object Class=StaticMeshComponent Name=PickupMesh StaticMesh=StaticMesh'UN_SimpleMeshes.TexPropCube_Dup' Materials(0)=Material'EditorMaterials.WidgetMaterial_Y' LightEnvironment=MyLightEnvironment Scale3D=(X=0.125, Y=0.125, Z=0.125) End Object Components.Add(PickupMesh) Begin Object Class=CylinderComponent Name=CollisionCylinder CollisionRadius=16.0 CollisionHeight=16.0 BlockNonZeroExtent=true BlockZeroExtent=true BlockActors=true CollideActors=true End Object CollisionComponent=CollisionCylinder Components.Add(CollisionCylinder) }

While looking through some tutorials I also found a way to change Flash elements directly from UnrealScript, which cuts down on memory overhead by eliminating redundant functions in Unrealscript and Actionscript.

Here is how to change a text in a text box:

var GFxObject RootMC; RootMC = GetObjectObject("_root.textboxInstanceName"); RootMC.SetText("Insert Text Here");

And here you can go to a frame of a movieclip:

RootMC = GetVariableObject("_root.movieclipInstanceName"); RootMC.GotoAndStopI(2); RootMC.GotoAndStop("Start");

I put two examples of how to go to a frame within a movie clip. The first one GotoandStopI() expects an integer as a parameter(that is why there is an "I" at the end) while GotoAndStop() expects a string. The string has to match a keyframe label you assigned in Flash.

Knowing how to do this now, I want to go back through the upgrade screen and optimize it more. Right now I have duplicate functions in AS3 and Unrealscript to get them to communicate all the information I needed to get through. With this I can do away with the hacky way of getting Unrealscript variables into AS3.

Thanks for reading, if you ever have any questions about my work, or suggestions on how to improve, don't hesitate to comment. I'm still new to this but will try and help as much as I can.

*On a side note: BlogTrog is a great little resource for making the code windows above. You just paste your text into the textfield on their site and select the language and it does the rest. Unfortunately they don't have Unrealscript or Actionscript 3 as languages you can select, but C# comes close in terms of highlighting.

No comments:

Post a Comment