There is one small caveat that can take some time to figure out when drawing a texture with DrawRect on Canvas. If you want the texture to appear just like in real, you have to SetColor to 255,255,255 before you actually call DrawRect function, otherwise the last set color settings will be used that may cause your texture to look differently (will kind of filter your texture with the color settings set on Canvas), e.g. Color set to 0,0,0 will make your texture look completely black. Took me some time to figure this out…
Sometimes it is very helpful to have two instances of UT2004 up and running at one system. This is actually possible when you run UT2004 like this from a bat file:
C:\WINDOWS\system32\cmd.exe /c start "UT2004" /belownormal "UT2004.exe" "127.0.0.1" C:\WINDOWS\system32\cmd.exe /c start "UT2004" /belownormal "UT2004.exe" "127.0.0.1"
After some experimenting I've got it working. Just attach it to the desired actor. ue2_beamemitter_example
It seems that in ut2004.ini the default settings of TCP net driver is not optimal and the performance can be boosted a little bit by setting variables better. Two links:
Seems that there is always something to learn. Today Jacob discovered Unreal ScriptProfiler - a great tool for profiling of .uc classes and user code. We have quickly discovered bottlenecks in GameBots2004 and optimized the code so it is about 4 times faster. There are non-trivial chains of calls of Unreal function and we were sometimes a bit surprised. More information here: http://udn.epicgames.com/Two/ScriptProfiler.html
Note that native functions are not profiled for some reason, so you have to “wrap” each native function call in your custom function and then you will be able to see the results.
Now this is really a gold nugget. The timing in Unreal IS NOT 1:1 to real time. It is roughly 10:9. There is this Level.TimeDilation = 1.1;
parameter set in GameInfo clas, that speeds up the things. This is why you can get hard time synchronizing times between OS and UT. Good to know for sure.
Note: This doesn't seem to be true in UnrealRuntime2 - the time dilation is set to 1 there.
Strange think yesterday. I was playing with displaying some game messages on the HUD. So I created my own GameReplicationInfo, I have spawned it in my GameInfo class, I've set it in replication statement, BUT this filed WAS NOT accessible on client from HUD class, when I tried to type MyGameType(Level.Game).myFieldName !!! Don't know why this does not work. However I could access this class with foreach DynamicActors(MyGameReplicationInfoClass, MyRepInfo) … So it seems the object IS replicated, just the reference is not - EVEN it is in replication statement. Maybe if I would set it in PostNetReceive function it would work - I did not try that. But that is a little bit complicated way I think.
Replication of animation and name variables seems to be a little bit broken. Only sure thing how to synchronize something immediately between client and server is to do it in PostNetReceive() function. So you define a variable that is replicated, a boolean that holds the information the variable has been changed (that is also replicated) and in PostNetReceive() function you can react to this change and use the new variable value for something ON client…
The synchronization between client and server location seems to behave differently when Pawn is spawned and where there is no pawn. Also when replication something the key word simulated may not be enough. Instead this statement seems to work:
reliable if( RemoteRole==ROLE_AutonomousProxy )
YOUR_REPLICATED_FUNCTION;
When no pawn is spawned you have to set the new Location and Rotation values on client and server.
Confirmed. simulated methods behave differently from methods declared in replication statement. To summarize, simulated methods does not work properly - it is better to declare in rep. statement.
EDIT: Because simulated keyword itself does not mean replication - just the possibility to call something on client at all (from example from other client side function etc.)
I've stumbled upon a problem. I had a medium sized map created in UnrealEd in UnrealEngine2Runtime and some big StaticMeshes packs. I wanted to change some textures in the StaticMeshes in my pack (they were already used in the map). For some reason, when I did the change and save it the changes were gone next time I opened the file. There is some bug in UnrealEd that causes some weird synchronization of StaticMeshes textures in StaticMesh pack (.usx) and the map itself.
The way of changing textures that worked was: 1) Open staticMeshes files, do the changes and save it to DIFFERENT file. 2) Export the map that used the StaticMeshes into t3d file. Then edit the t3d file so it reflects the changes made previously to StaticMesh file + reroute all links to new StaticMesh file. 3) Import the map from this editted t3d file. The textures will be changed.
Phew…
Just go to the UDK/UDKGame/Config
folder and there either in UDKGame.ini
or better directly in YOUR_MOD_NAME.ini
find the game type you want to extend and set TimeLimit
value (in minutes) to your desired value. E.g. TimeLimit=1000
for 1000 minutes until game end (game may still end earlier if players achieve the game objectives - frags, flags, etc.).
OK, so there is one more nice catch in UDK. The function calls are replicated ONLY for client PlayerController class and its descendants - the Pawn it owns and Inventory it owns. If you want replicate function calls from server to client on other objects you can't. This was little bit surprising for me.
You can bypass this by using variable replication and repnotify statement. When you define some replicated variable with repnotify keyword it means that every time new value is replicated to client function simulated event ReplicatedEvent(name VarName) will be called on client. This is now only way how to execute something on client from server on non client-PlayerController owned objects. Be careful though - only NEW values are replicated. If you already replicated a value (even if you reset the value on client afterwards) new value will be replicated ONLY if it differs from last replicated value! So basically a hack how to replicate missing function calls is now to replicate all function attributes and then one dummy repnotify replicated integer value that will be just increased. You catch the replication of this dummy variable in ReplicatedEvent function and upon this you execute some simulated function on client taking the other replicated variables as its parameters. Sorry, but I don't find this approach very clean.
If I got it right, the simulated keyword does not mean that when I call the function on server the function call will be actually replicated on client… Simulated keyword only assures that the function CAN be called on client when some other function ON CLIENT tries to call it. When I want to have the function call replicated from server to client what I want to use is reliable client keywords - this assures the function call will be actually replicated.
To make a transparent texture in UDK you have to load texture with transparent color through the editor. Then create new Material using you texture, set blending style to Translucent and add two connections - one to Diffuse (from the upper black square) and the second to Opacity (from the lower white square). Save and it should work.
I've started to play with UDK recently. First a little bit complicated thing was to rewrite ray visualization emitter from UT2004 to UDK. It seems that replication works better in UDK than in UT2004. The code of the emitter: udk_code_rayvisualizer