Results 1 to 25 of 25
  1. #1
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Posts
    58

    Default Canvas Radar and Minimap

    So in this thread i want to show you, how you make a custom Hud and a radar and a minimap, only with Canvas.
    It's a working update of this tutorial:
    http://udn.epicgames.com/Three/Maste...G%20INTERFACES

    I've uploaded the needed packages:
    http://www.gamefront.com/files/21314684/Content.zip

    1. Create a custom gametype:

    Code:
    class MyGame extends UTGame;
    
    var MU_Minimap GameMinimap;
    
    defaultproperties
    {
            HUDType=class'YourPackage.CustomHUD'
            bUseClassicHUD = true
            
    }
    2. Create other classes:

    Code:
    class MU_Minimap extends Compass;
    
    var() MaterialInstanceConstant Minimap;
    var() MaterialInstanceConstant CompassOverlay;
    
    var Vector2D MapRangeMin,MapRangeMax;
    
    var() Bool bForwardAlwaysUp;
    
    var Vector2D MapCenter;
    
    var() Const EditConst DrawSphereComponent MapExtentsComponent;
    
    function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    
    	MapCenter.X = Location.X;
    	MapCenter.Y = Location.Y;
    	MapRangeMin.X = MapCenter.X - MapExtentsComponent.SphereRadius;
    	MapRangeMax.X = MapCenter.X + MapExtentsComponent.SphereRadius;
    	MapRangeMin.Y = MapCenter.Y - MapExtentsComponent.SphereRadius;
    	MapRangeMax.Y = MapCenter.Y + MapExtentsComponent.SphereRadius;
    }
    
    defaultproperties
    {
    	Begin Object Class=DrawSphereComponent Name=DrawSphere0
         	SphereColor=(B=0,G=255,R=0,A=255)
         	SphereRadius=5000.000000
    	End Object
    	MapExtentsComponent=DrawSphere0
    	Components.Add(DrawSphere0)
    
    	bForwardAlwaysUp=True
    	Minimap = MaterialInstanceConstant'CompassContent.M_minimap_INST'
        CompassOverlay = MaterialInstanceConstant'CompassContent.M_compass_INST'
    }
    Code:
    interface ICompass;
    
    function float GetDegreeHeading();
    function float GetRadianHeading();
    
    function int GetYaw();
    function Rotator GetRotator();
    function vector GetVectorizedRotator();
    Code:
    class Compass extends actor placeable implements(ICompass);
    
    event PostBeginPlay()
    {                                                             
     	`log(GetRadianHeading()@GetDegreeHeading(),,'compass heading');
    }
    
    function float GetRadianHeading()
    {
    	local Vector v;
    	local Rotator r;
    	local float f;
     
    	r.Yaw = rotation.Yaw;   // a
    	v = vector(r);          // b
    
    	f = GetHeadingAngle(v); // c
    	f = UnwindHeading(f);   // d
    
    	while (f < 0)		    // e
    		f += PI * 2.0f;
    
    	return f;
    } 
    
    function float GetDegreeHeading()
    {
    	local float f;
    
    	f = GetRadianHeading();
    
    	f *= RadToDeg;
    
    	return f;
    }
    
    // Return the yaw of the actor
    function int GetYaw()
    {
    	return Rotation.Yaw;
    }
    					  
    function Rotator GetRotator()
    {
    	return Rotation;
    }
    
    function vector GetVectorizedRotator()
    {
    	return vector(Rotation);
    }
    
    DefaultProperties
    {
    	Begin Object Class=ArrowComponent Name=Arrow
    		ArrowColor = (B=80,G=80,R=200,A=255)
    		ArrowSize = 1.000000
    		Name = "North Heading"
    	End Object
    	Components(0) = Arrow
    
    	Begin Object Class=SpriteComponent Name=Sprite 
    		Sprite=Texture2D'UTBookTextures.compass'
    		HiddenGame = True
    		AlwaysLoadOnClient = False
    		AlwaysLoadOnServer = False
    		Name  = "Sprite"
    	End Object
    	Components(1) = Sprite
    
    	bStatic   = True
    	bHidden   = True
    	bNoDelete = True
    	bMovable  = False
    }

    3. Now the Hud :
    There will be a warning on the screen
    You can disable it, be typing "DisableAllScreenMessages" into the console

    Code:
    class CustomHUD extends UTHUD;
    
    var MaterialInstanceConstant GameMinimapMIC;
    var Material GameMinimapp;
    
    var MU_Minimap GameMinimap;
    var Float TileSize;
    var Int MapDim;
    var Int BoxSize;
    var color PlayerColors[2];
    
    var float MPosXMap;
    var float MPosYMap;
    
    simulated function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    
    	GameMinimap = Mygame(WorldInfo.Game).GameMinimap;
    }
    
    
    function DrawLivingHUD()
    {
        DrawMap();
    
        MPosXMap = Canvas.OrgX + 30;
        MPosYMap = Canvas.ClipY/1.6;
    }
    
    
    /////////////////////////////////
    //Radar/Minimap
    /////////////////////////////////
    
    function float GetPlayerHeading()
    {
    	local Float PlayerHeading;
    	local Rotator PlayerRotation;
    	local Vector v;
    
    	PlayerRotation.Yaw = PlayerOwner.Pawn.Rotation.Yaw;
    	v = vector(PlayerRotation);
    	PlayerHeading = GetHeadingAngle(v);
    	PlayerHeading = UnwindHeading(PlayerHeading);
    
    	while (PlayerHeading < 0)
    		PlayerHeading += PI * 2.0f;
    
    	return PlayerHeading;
    }
    
    
    //There will be a warning on the screen
    //You can disable it, be typing "DisableAllScreenMessages"
    
    function DrawMap()
    {
    	local Float TrueNorth,PlayerHeading;
    	local Float MapRotation,CompassRotation;
    	local Vector PlayerPos, ClampedPlayerPos, RotPlayerPos, DisplayPlayerPos, StartPos;
    	local LinearColor MapOffset;
    	local Float ActualMapRange;
    	local Controller C;
    
    	//Set MapDim & BoxSize accounting for the current resolution
    	MapPosition.X = MPosXMap;  //default.MapPosition.X * FullWidth;
    	MapPosition.Y = MPosYMap;  //default.MapPosition.Y * FullHeight;
    	MapDim = default.MapDim * ResolutionScale;
    	BoxSize = default.BoxSize * ResolutionScale;
    
    	//Calculate map range values
    	ActualMapRange = FMax(	GameMinimap.MapRangeMax.X - GameMinimap.MapRangeMin.X,
    						GameMinimap.MapRangeMax.Y - GameMinimap.MapRangeMin.Y);
    
    	//Calculate normalized player position
    	PlayerPos.X = (PlayerOwner.Pawn.Location.Y - GameMinimap.MapCenter.Y) / ActualMapRange;
    	PlayerPos.Y = (GameMinimap.MapCenter.X - PlayerOwner.Pawn.Location.X) / ActualMapRange;
    
    	//Calculate clamped player position
    	ClampedPlayerPos.X = FClamp(PlayerPos.X,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    	ClampedPlayerPos.Y = FClamp(PlayerPos.Y,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    
    	//Get north direction and player's heading
    	TrueNorth = GameMinimap.GetRadianHeading();
    	Playerheading = GetPlayerHeading();
    
    	//Calculate rotation values
    	if(GameMinimap.bForwardAlwaysUp)
    	{
    		MapRotation = PlayerHeading;
    		CompassRotation = PlayerHeading - TrueNorth;
    	}
    	else
    	{
    		MapRotation = PlayerHeading - TrueNorth;
    		CompassRotation = MapRotation;
    	}
    
    	//Calculate position for displaying the player in the map
    	DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan(PlayerPos.X) - MapRotation);
    	DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan(PlayerPos.Y) - MapRotation);
    
    	//Calculate player location after rotation
    	RotPlayerPos.X = VSize(ClampedPlayerPos) * Cos( ATan(ClampedPlayerPos.X) - MapRotation);
    	RotPlayerPos.Y = VSize(ClampedPlayerPos) * Sin( ATan(ClampedPlayerPos.Y) - MapRotation);
    
    	//Calculate upper left UV coordinate
    	StartPos.X = FClamp(RotPlayerPos.X + (0.5 - (TileSize / 2.0)),0.0,1.0 - TileSize);
    	StartPos.Y = FClamp(RotPlayerPos.Y + (0.5 - (TileSize / 2.0)),0.0,1.0 - TileSize);
    	StartPos.X = FClamp(DisplayPlayerPos.X + (0.5 - (TileSize / 2.0)),TileSize/-2,1.0 - TileSize/2);
    	StartPos.Y = FClamp(DisplayPlayerPos.Y + (0.5 - (TileSize / 2.0)),TileSize/-2,1.0 - TileSize/2);
    
    	//Calculate texture panning for alpha
    	MapOffset.R =  FClamp(-1.0 * RotPlayerPos.X,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    	MapOffset.G =  FClamp(-1.0 * RotPlayerPos.Y,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    	MapOffset.R =  FClamp(-1.0 * DisplayPlayerPos.X,-0.5,0.5);
    	MapOffset.G =  FClamp(-1.0 * DisplayPlayerPos.Y,-0.5,0.5);
    
    
            //Set the material parameter values
    	GameMinimap.Minimap.SetScalarParameterValue('MapRotation',MapRotation);
    	GameMinimap.Minimap.SetScalarParameterValue('TileSize',TileSize);
    	GameMinimap.Minimap.SetVectorParameterValue('MapOffset',MapOffset);
    	GameMinimap.CompassOverlay.SetScalarParameterValue('CompassRotation',CompassRotation);
    
    	//Draw the map
    	Canvas.SetPos(MapPosition.X,MapPosition.Y);
    	Canvas.DrawMaterialTile(GameMinimap.Minimap,MapDim,MapDim,StartPos.X,StartPos.Y,TileSize,TileSize);
    
    	//Draw the player's location
    	Canvas.SetPos(	MapPosition.X + MapDim * (((DisplayPlayerPos.X + 0.5) - StartPos.X) / TileSize) - (BoxSize / 2),
    				MapPosition.Y + MapDim * (((DisplayPlayerPos.Y + 0.5) - StartPos.Y) / TileSize) - (BoxSize / 2));
    	Canvas.SetDrawColor(PlayerColors[0].R,
    					PlayerColors[0].G,
    					PlayerColors[0].B,
    					PlayerColors[0].A);
    	Canvas.DrawBox(BoxSize,BoxSize);
    	//Canvas.DrawMaterialTile(PlayerTex, 1400 * ResolutionScale, 900 * ResolutionScale);
    
    	/*****************************
    	*  Draw Other Players
    	*****************************/
    
    	foreach WorldInfo.AllControllers(class'Controller',C)
    	{
    		if(PlayerController(C) != PlayerOwner)
    		{
    			//Calculate normalized player position
    			PlayerPos.Y = (GameMinimap.MapCenter.X - C.Pawn.Location.X) / ActualMapRange;
    			PlayerPos.X = (C.Pawn.Location.Y - GameMinimap.MapCenter.Y) / ActualMapRange;
    
    			//Calculate position for displaying the player in the map
    			DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan(PlayerPos.X) - MapRotation);
    			DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan(PlayerPos.Y) - MapRotation);
    
    			if(VSize(DisplayPlayerPos - RotPlayerPos) <= ((TileSize / 2.0) - (TileSize * Sqrt(2 * Square(BoxSize / 2)) / MapDim)))
    			{
    				//Draw the player's location
    				Canvas.SetPos(	MapPosition.X + MapDim * (((DisplayPlayerPos.X + 0.5) - StartPos.X) / TileSize) - (BoxSize / 2),
    							MapPosition.Y + MapDim * (((DisplayPlayerPos.Y + 0.5) - StartPos.Y) / TileSize) - (BoxSize / 2));
    				Canvas.SetDrawColor(PlayerColors[1].R,
    								PlayerColors[1].G,
    								PlayerColors[1].B,
    								PlayerColors[1].A);
    				Canvas.DrawBox(BoxSize,BoxSize);
    			}
    		}
    	}
    
    	//Draw the compass overlay
    	Canvas.SetPos(MapPosition.X,MapPosition.Y);
    	Canvas.DrawMaterialTile(GameMinimap.CompassOverlay,MapDim,MapDim,0.0,0.0,1.0,1.0);
    }
    
    
    exec function ChangeMapsize(int size)
    {
       MapDim = size;
    
    }
    
    exec function MapSizeUp()
    {
    	MapDim *= 2;
    	BoxSize *= 2;
    }
    
    exec function MapSizeDown()
    {
    	MapDim /= 2;
    	BoxSize /= 2;
    }
    
    exec function MapZoomIn()
    {
    	TileSize = 1.0 / FClamp(int((1.0 / TileSize) + 1.0) + 0.5,1.5,10.5);
    	TileSize = 1.0 / FClamp(int((1.0 / TileSize) + 1.0) + 0.5,1.5,10.5);
    
    }
    
    exec function MapZoomOut()
    {
    	TileSize = 1.0 / FClamp(Int((1.0 / TileSize) - 1.0) + 0.5,1.5,10.5);
    }
    
    
    defaultproperties
    {
            MapDim=256
    	BoxSize=12
    	PlayerColors(0)=(R=255,G=255,B=255,A=255)
    	PlayerColors(1)=(R=96,G=255,B=96,A=255)
    	TileSize=1
    	MapPosition=(X=0.000000,Y=0.000000)
    
    }

    Now we are done with coding.
    In your level, you have to place a MU_Minimap actor (Select the Actor classes Tab and search for this actor)
    You have to play with the radius (select the MU_Minimap actor and press F4) until it fits the size of your level.

    If you've got any questions PN me or write a message in this thread!

  2. #2
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    Quote Originally Posted by marco6453 View Post
    3. Now the Hud :
    There will be a warning on the screen
    You can disable it, be typing "DisableAllScreenMessages" into the console
    Isn't that warning there for a reason? I've been struggling with it myself and I don't have a solution but this seems like homer simpson putting a plaster over the engine management light to make the problem go away.

    The warning is MIC::SetVectorParameterValue : Modifying 'your_material_name' during gameplay

  3. #3

  4. #4
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    Quote Originally Posted by marco6453 View Post
    Ah, ok. Fixed my code. Thanks! I cant see where you've done that in the code you've posted (it may be in the zip but I didn't download that as I'd already been through the same conversion process as you).

  5. #5

    Question HELP:radar/compass

    Hi there, before i begin i'd just like to add im pretty noobish when it comes to Unreal scripting. BUT i want to learrn!

    As much help you have been breaking that old massive tutorial UDN gave us, im still struggling to get this compass working, and i really need it working for my dissertation.

    SO ive followed the tutorial marco6453 provided us with. Ive created the UC files(do i need to compile these to U files, if so how??) and ive put them in here Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes is that right?

    The MU_minimap actor and Compass actor comes up if i search it in actor classes in udk. and I've followed the big UDN tutorial. Im pretty sure ive done everything. including cooking the map file and running it.Also rebuilding scripts. But it still does not come up with the compass...

    I know im a noob, but everyone starts somewhere...
    Any speedy response would be appreciated.
    Thanks Alot in advance!

  6. #6
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    From what you've written I think the bit you are missing is setting up the project so the build script picks up your code. Building the scripts is the bit that turns your code into a .U file named the same as the directory you stored it in.

    Have a read through the project set up section, see if theres anything you missed (I'm guessing the ModEditPackages pointing at your source code bit).

    http://udn.epicgames.com/Three/Devel...t.html#Project setup

    If it's still not working after that post the output from your build. Once we know its built the U files the next step is checking your game class is definitely loading.
    Last edited by GeekyPayback; 02-28-2012 at 04:44 AM.

  7. #7

    Default

    UDK is already looking at myMod folder in devlopment/src. However, its still not working...maybe i implemented it wrong? how can i check my classes are loaded correctly?
    thanks again and sorry for the late reply.

  8. #8
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    Paste the contents of your UDKEngine.ini and the results of the compile. After we have both of those we should know what the problem is (nb. use the [code ] tags to make it readable on this forum)

  9. #9

    Default

    I implemented the code given on the mastering unreal script tutorial...
    Code:
    Init: Version: 8710
    Init: Epic Internal: 0
    Init: Compiled (32-bit): Jul 18 2011 18:37:12
    Init: Command line: 
    Init: Base directory: Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\Win32\
    Init: Character set: Unicode
    Log: Executing Class UnrealEd.MakeCommandlet
    --------------------Core - Release--------------------
    --------------------Engine - Release--------------------
    --------------------GFxUI - Release--------------------
    --------------------GameFramework - Release--------------------
    --------------------UnrealEd - Release--------------------
    --------------------GFxUIEditor - Release--------------------
    --------------------IpDrv - Release--------------------
    --------------------OnlineSubsystemPC - Release--------------------
    --------------------OnlineSubsystemSteamworks - Release--------------------
    --------------------UDKBase - Release--------------------
    --------------------UTEditor - Release--------------------
    --------------------UTGame - Release--------------------
    --------------------UTGameContent - Release--------------------
    --------------------MyMod - Release--------------------
    Analyzing...
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes\MinimapGame.uc(11) : Warning, Unresolved reference to Class 'MasteringUnrealScript.MU_Minimap'
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes\MinimapGame.uc(11) : Error, Call to 'AllActors', parameter 2: Type mismatch in Out variable
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes\MinimapHUD.uc(106) : Error, Call to 'ATan': Function only takes 1 parameter(s)
    Compile aborted due to errors.
    
    Warning/Error Summary
    ---------------------
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes\MinimapGame.uc(11) : Error, Call to 'AllActors', parameter 2: Type mismatch in Out variable
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes\MinimapHUD.uc(106) : Error, Call to 'ATan': Function only takes 1 parameter(s)
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod\Classes\MinimapGame.uc(11) : Warning, Unresolved reference to Class 'MasteringUnrealScript.MU_Minimap'
    
    Failure - 2 error(s), 1 warning(s)
    Execution of commandlet took:  4.64 seconds
    [Mar 14, 8:22 PM] COMMANDLET 'UDK.exe make' FAILED
    Thats the compile errors for the unrealscript tutorial source files.

    Heres the compile errors for the code from this post.
    Code:
    Analyzing...
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\CompassActor.uc : Error, Script vs. class name mismatch (CompassActor/CustomHUD)
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\CompassActor.uc : Error, Script vs. class name mismatch (CompassActor/CustomHUD)
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\MinimapGame.uc : Error, Script vs. class name mismatch (MinimapGame/MyGame)
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\MinimapGame.uc : Error, Script vs. class name mismatch (MinimapGame/MyGame)
    Error, Superclass Compass of class MU_Minimap not found
    Compile aborted due to errors.
    
    Warning/Error Summary
    ---------------------
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\CompassActor.uc : Error, Script vs. class name mismatch (CompassActor/CustomHUD)
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\MinimapGame.uc : Error, Script vs. class name mismatch (MinimapGame/MyGame)
    Error, Superclass Compass of class MU_Minimap not found
    
    Failure - 5 error(s), 0 warning(s)
    Execution of commandlet took:  18.48 seconds
    [Mar 14, 8:49 PM] COMMANDLET 'UDK.exe make -full' FAILED
    Code:
    [UnrealEd.EditorEngine]
    LocalPlayerClassName=UnrealEd.EditorPlayer
    bSubtitlesEnabled=True
    GridEnabled=True
    SnapScaleEnabled=True
    ScaleGridSize=5
    SnapVertices=False
    SnapDistance=10.000000
    GridSize=(X=16.000000,Y=16.000000,Z=16.000000)
    RotGridEnabled=True
    RotGridSize=(Pitch=1024,Yaw=1024,Roll=1024)
    GameCommandLine=-log
    FOVAngle=90.000000
    GodMode=True
    AutoSaveDir=..\..\UDKGame\Autosaves
    InvertwidgetZAxis=True
    UseAxisIndicator=True
    MatineeCurveDetail=0.1
    Client=WinDrv.WindowsClient
    CurrentGridSz=4
    bUseMayaCameraControls=True
    bPrefabsLocked=True
    HeightMapExportClassName=TerrainHeightMapExporterTextT3D
    EditorOnlyContentPackages=EditorMeshes
    EditorOnlyContentPackages=EditorMaterials
    EditorOnlyContentPackages=EditorResources
    EditPackagesInPath=..\..\Development\Src
    EditPackages=Core
    EditPackages=Engine
    EditPackages=GFxUI
    EditPackages=GameFramework
    EditPackages=UnrealEd
    EditPackages=GFxUIEditor
    EditPackages=IpDrv
    EditPackages=OnlineSubsystemPC
    EditPackages=OnlineSubsystemGameSpy
    EditPackages=OnlineSubsystemLive
    EditPackages=OnlineSubsystemSteamworks
    bBuildReachSpecs=FALSE
    bGroupingActive=TRUE
    bCustomCameraAlignEmitter=TRUE
    CustomCameraAlignEmitterDistance=100.0
    bDrawSocketsInGMode=FALSE
    bSmoothFrameRate=FALSE
    MinSmoothedFrameRate=5
    MaxSmoothedFrameRate=120
    FarClippingPlane=0
    TemplateMapFolders=..\..\Engine\Content\Maps\Templates
    EditPackagesOutPath=..\..\UDKGame\Script
    FRScriptOutputPath=..\..\UDKGame\ScriptFinalRelease
    EditPackages=UDKBase
    EditPackages=UTEditor
    InEditorGameURLOptions=?quickstart=1?numplay=1
    EditPackages=UTGame
    EditPackages=UTGameContent
    ModEditPackages=MyMod
    and thats the UDKengine.ini file
    :/ Im pretty sure the engine file is fine. i htink im just being a noob trying to implement the compass classes.
    Also im pretty sure it shouldnt be looking in Binaries... :
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes
    my mod classes is in here
    Z:\Program Files (x86)\UDK\UDK-2011-07\Development\Src\MyMod

    thanks again
    Last edited by Andychung91; 03-14-2012 at 04:56 PM.

  10. #10
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    So the answer to your original problem is that your code doesn't compile. This means your .u file is not created, and that's why the game isn't finding the class you created.

    Forget about the original code and concentrate on what you've got from this thread.

    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\Compa ssActor.uc : Error, Script vs. class name mismatch (CompassActor/CustomHUD)
    Z:\Program Files (x86)\UDK\UDK-2011-07\Binaries\..\Development\Src\MyMod\Classes\Minim apGame.uc : Error, Script vs. class name mismatch (MinimapGame/MyGame)

    Unrealscript requires that the classname matches the the filename. I dont understand why its throwing extra values on the end - "CompassActor/CustomHUD"

    Could you paste the contents of Development\Src\MyMod\Classes\CompassActor.uc as I think that will contain the source of your problem.
    Last edited by GeekyPayback; 03-16-2012 at 11:53 AM.

  11. #11

    Default

    Hello, maybe someone can help me, i'm having some weird problems with the minimap.
    First screenshot:

    As you can see i am walking straight from the bottom to the top. Now compare the Position with the Position on the Minimap,
    if i pass the MapCenter the position is negated on the Minimap and the Position is the same as i started (dont know how to explain this better :/)
    also for some reason the position on the Minimap only works for Y Axis,
    walking left to right ends on an up-down movement on the minimap, the x value is always around ~0.

    Hope someone understands what i am saying (probably not xD), have problems with explaining things in english.

    Also here is my DrawMap function: (its nearly the same as in the OP)
    Code:
    function DrawMap()
    {
    	local Float TrueNorth,PlayerHeading;
    	local Float MapRotation,CompassRotation;
    	local Vector PlayerPos, ClampedPlayerPos, RotPlayerPos, DisplayPlayerPos, StartPos;
    	local LinearColor MapOffset;
    	local Float ActualMapRange;
    	local Controller C;
    
    	local UnLoaded_PlayerController PC;
    	PC = UnLoaded_PlayerController(PlayerOwner);
    
    	//Set MapDim & BoxSize accounting for the current resolution
    	MapPosition.X = default.MapPosition.X;
    	MapPosition.Y = default.MapPosition.Y;
    	MapDim = default.MapDim * ResScaleX;
    	BoxSize = default.BoxSize * ResScaleX;
    
    	//Calculate map range values
    	ActualMapRange = FMax(	GameMinimap.MapRangeMax.X - GameMinimap.MapRangeMin.X,
    						GameMinimap.MapRangeMax.Y - GameMinimap.MapRangeMin.Y);
    
    	//Calculate normalized player position
    	PlayerPos.X = (PC.Pawn.Location.Y - GameMinimap.MapCenter.Y) / ActualMapRange;
    	PlayerPos.Y = (GameMinimap.MapCenter.X - PC.Pawn.Location.X) / ActualMapRange;
    
    	//Calculate clamped player position
    	ClampedPlayerPos.X = FClamp(PlayerPos.X,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    	ClampedPlayerPos.Y = FClamp(PlayerPos.Y,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    
    	//Get north direction and player's heading
    	TrueNorth = GameMinimap.GetRadianHeading();
    	Playerheading = GetPlayerHeading();
    
    	//Calculate rotation values
    	if(GameMinimap.bForwardAlwaysUp)
    	{
    		MapRotation = PlayerHeading;
    		CompassRotation = PlayerHeading - TrueNorth;
    	}
    	else
    	{
    		MapRotation = PlayerHeading - TrueNorth;
    		CompassRotation = MapRotation;
    	}
    
    	//Calculate position for displaying the player in the map
    	DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan(PlayerPos.X) - MapRotation);
    	DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan(PlayerPos.Y) - MapRotation);
    
    	//Calculate player location after rotation
    	RotPlayerPos.X = VSize(ClampedPlayerPos) * Cos( ATan(ClampedPlayerPos.X) - MapRotation);
    	RotPlayerPos.Y = VSize(ClampedPlayerPos) * Sin( ATan(ClampedPlayerPos.Y) - MapRotation);
    
    	//Calculate upper left UV coordinate
    	StartPos.X = FClamp(RotPlayerPos.X + (0.5 - (TileSize / 2.0)),0.0,1.0 - TileSize);
    	StartPos.Y = FClamp(RotPlayerPos.Y + (0.5 - (TileSize / 2.0)),0.0,1.0 - TileSize);
    	StartPos.X = FClamp(DisplayPlayerPos.X + (0.5 - (TileSize / 2.0)),TileSize/-2,1.0 - TileSize/2);
    	StartPos.Y = FClamp(DisplayPlayerPos.Y + (0.5 - (TileSize / 2.0)),TileSize/-2,1.0 - TileSize/2);
    
    	//Calculate texture panning for alpha
    	MapOffset.R =  FClamp(-1.0 * RotPlayerPos.X,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    	MapOffset.G =  FClamp(-1.0 * RotPlayerPos.Y,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    	MapOffset.R =  FClamp(-1.0 * DisplayPlayerPos.X,-0.5,0.5);
    	MapOffset.G =  FClamp(-1.0 * DisplayPlayerPos.Y,-0.5,0.5);
    
    
            //Set the material parameter values
    	MiniMapInst.SetScalarParameterValue('MapRotation',MapRotation);
    	MiniMapInst.SetScalarParameterValue('TileSize',TileSize);
    	MiniMapInst.SetVectorParameterValue('MapOffset',MapOffset);
    	CompassInst.SetScalarParameterValue('CompassRotation',CompassRotation);
    
    	//Draw the map
    	Canvas.SetPos(MapPosition.X,MapPosition.Y);
    	Canvas.DrawMaterialTile(MiniMapInst,MapDim,MapDim,StartPos.X,StartPos.Y,TileSize,TileSize);
    
    	//Draw the player's location
    	Canvas.SetPos(	MapPosition.X + MapDim * (((DisplayPlayerPos.X + 0.5) - StartPos.X) / TileSize) - (BoxSize / 2),
    				MapPosition.Y + MapDim * (((DisplayPlayerPos.Y + 0.5) - StartPos.Y) / TileSize) - (BoxSize / 2));
    	Canvas.SetDrawColor(PlayerColors[0].R,
    					PlayerColors[0].G,
    					PlayerColors[0].B,
    					PlayerColors[0].A);
    	Canvas.DrawBox(BoxSize,BoxSize);
    
    	/*****************************
    	*  Draw Other Players
    	*****************************/
    
    	foreach WorldInfo.AllControllers(class'Controller',C)
    	{
    		if(PlayerController(C) != PC)
    		{
    		}
    	}
    
    	//Draw the compass overlay
    	Canvas.SetPos(MapPosition.X,MapPosition.Y);
    	Canvas.DrawMaterialTile(CompassInst,MapDim,MapDim,0.0,0.0,1.0,1.0);
    }
    I dont see whats wrong, i tried the UDN example and this one, both with the same weird behavior, btw i am using the February UDK.
    Also why does the ATan function now only excepts 1 parameter and how to convert the earlier ATan with 2 parameters to the new one?

  12. #12

    Default

    Ok, so i did a fresh install of udk, coppied my map files over and implemented the code from this thread and placed an mu_minimap actor in and played around with the textures that it needs to display. The scripts compiles but with warnings...

    Code:
    Z:\Program Files (x86)\FreshUDK\Development\Src\MyMod\Classes\MU_Minimap.uc(36) : Warning, ObjectProperty MyMod.MU_Minimap:Minimap: unresolved reference to 'MaterialInstanceConstant'CompassContent.M_minimap_INST''
    Z:\Program Files (x86)\FreshUDK\Development\Src\MyMod\Classes\MU_Minimap.uc(36) : Warning, Invalid property value in defaults:     Minimap = MaterialInstanceConstant'CompassContent.M_minimap_INST'
    Z:\Program Files (x86)\FreshUDK\Development\Src\MyMod\Classes\MU_Minimap.uc(37) : Warning, ObjectProperty MyMod.MU_Minimap:CompassOverlay: unresolved reference to 'MaterialInstanceConstant'CompassContent.M_compass_INST''
    Z:\Program Files (x86)\FreshUDK\Development\Src\MyMod\Classes\MU_Minimap.uc(37) : Warning, Invalid property value in defaults:     CompassOverlay = MaterialInstanceConstant'CompassContent.M_compass_INST'
    Z:\Program Files (x86)\FreshUDK\Development\Src\MyMod\Classes\MyGame.uc(7) : Warning, ClassProperty Engine.GameInfo:HUDType: unresolved reference to 'class'YourPackage.CustomHUD''
    Z:\Program Files (x86)\FreshUDK\Development\Src\MyMod\Classes\MyGame.uc(7) : Warning, Invalid property value in defaults:         HUDType=class'YourPackage.CustomHUD'
    MU_minimap.uc
    Code:
    36:Minimap = MaterialInstanceConstant'CompassContent.M_minimap_INST' 
    37:CompassOverlay = MaterialInstanceConstant'CompassContent.M_compass_INST'
    MyGame.uc
    Code:
    7:HUDType=class'YourPackage.CustomHUD'
    Also, when i cook the map it cooks fine, and launches fine... but it doesnt give me the option to run it in "MyGame" mode only DM TDM and CTF. Ive changed it in the world properties but theres no change

    Thanks again :P

  13. #13

    Default

    Quote Originally Posted by Eikester View Post
    -snip-
    Fixed!

    Replaced this:
    Code:
    //Calculate position for displaying the player in the map
    	DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan(PlayerPos.X) - MapRotation);
    	DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan(PlayerPos.Y) - MapRotation);
    
    	//Calculate player location after rotation
    	RotPlayerPos.X = VSize(ClampedPlayerPos) * Cos( ATan(ClampedPlayerPos.X) - MapRotation);
    	RotPlayerPos.Y = VSize(ClampedPlayerPos) * Sin( ATan(ClampedPlayerPos.Y) - MapRotation);
    with this:
    Code:
    //Calculate position for displaying the player in the map
    	DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan2(PlayerPos.Y, PlayerPos.X) - MapRotation);
    	DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan2(PlayerPos.Y, PlayerPos.X) - MapRotation);
    
    	//Calculate player location after rotation
    	RotPlayerPos.X = VSize(ClampedPlayerPos) * Cos( ATan2(ClampedPlayerPos.Y, ClampedPlayerPos.X) - MapRotation);
    	RotPlayerPos.Y = VSize(ClampedPlayerPos) * Sin( ATan2(ClampedPlayerPos.Y, ClampedPlayerPos.X) - MapRotation);

  14. #14

    Default

    ok well, Ive seemed to of solved them errors by replacing the package name with my compass package name and "yourpackage" with myMod where my scripts are stored.
    So now all scripts are building fine, the map is cooking fine... but i still cant get this damn compass to apear what am i doing wrong?!

  15. #15

    Default

    Hey Im still stuck on this minimap...Please Help!
    I have used the code from this post. but i have a feeling im implementing it wrong.
    This is what i have done so far.





    Also I have chosen MyGame as the game type, which is what the gametype is called in the code... What really confuses me is why it loads up in DM mode with full HUD...

    "none" Gametype...All my kismet still works.. and there is no compass or hud...


    Were as when i put it on 'MyGame' game type it comes up like a DM HUD with no compass(apart from the default radar). Surely it must be reading in the gametype if i can select it in the editor...Also my kismet does not all my kismet works in this class :/


    What am i doing wrong? please help
    btw i am greatful for those who have helped me so far! you guys are great.
    Last edited by Andychung91; 03-21-2012 at 05:42 PM. Reason: More info

  16. #16

    Default

    Hi, I followed this tutorial and I did everything I could have done to make this work but the only issue im coming up with is that the minimap is not showing up in my HUD. Ive added the minimap actor into my scene and played around with the dimensions but no avail. (I do have the package imported into UDK.)

  17. #17

    Default

    Quote Originally Posted by Eikester View Post
    Fixed!
    That guy is right, if you getting wrong positioning on your minimap. Although, you must not forget to do the similar thing with atan functions for drawing other players.

    If you can't see your map, try to draw with the canvas something in the end of your drawmap-function, for example, some text with the strict coordinates.
    It doesn't appear too => your function wasn't been called, seek for correct calling.
    Drawn canvas appears, other HUD doesn't => look into the positioning of drawing functions, could be some mistakes there and so on, HUD can't be drawn (still, just a theory).

    And place your minimap-actor extremely carefully. Especially if you have multiple streaming levels. In my case, it actually worked only when being placed within persistent one.

  18. #18
    The Sacrifice
    Join Date
    Nov 2009
    Posts
    228
    Gamer IDs

    Gamertag: GeekyPayback

    Default

    Edit: Sorry, read the problem wrong. I'd stick a log at the top of your postrender function in the custom hud to check its getting called. That's the start point for drawing the map. If your log gets spammed with the message we know its a variable somewhere thats stopping the code reaching your map function
    Last edited by GeekyPayback; 05-15-2012 at 07:28 AM.

  19. #19
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,819
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    hello, i'm trying to use this tutorial to add the radar to my game extending from UDKGame, all seems to be working right, but i have a little issue, when i draw the minimap on the screen the map texture will not draw complete, here is a picture of it

    This Image Was Automatically Resized by using the Screenshot Tag.  Click to view the full version

    any idea on why my floor texture is not drawing in the right way ?

    thanks in advance for all the help.
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  20. #20

    Default

    Quote Originally Posted by Andychung91 View Post
    ok well, Ive seemed to of solved them errors by replacing the package name with my compass package name and "yourpackage" with myMod where my scripts are stored.
    So now all scripts are building fine, the map is cooking fine... but i still cant get this damn compass to apear what am i doing wrong?!
    Quote Originally Posted by Jimster092 View Post
    Hi, I followed this tutorial and I did everything I could have done to make this work but the only issue im coming up with is that the minimap is not showing up in my HUD. Ive added the minimap actor into my scene and played around with the dimensions but no avail. (I do have the package imported into UDK.)
    For those that have followed this tutorial and are not seeing the minimap on your HUD, this is what I did.

    After attempting numerous solutions, I finally added the following function to MyGame class:
    Code:
    class MyGame extends UTGame;
    
    var MU_Minimap GameMinimap;
    
    function InitGame( string Options, out string ErrorMessage )
    {
    	local MU_Minimap ThisMinimap;
    
    	Super.InitGame(Options,ErrorMessage);
    	
    	foreach AllActors(class'MyMod.MU_Minimap',ThisMinimap)
    	{
    		GameMinimap = ThisMinimap;
    		break;
    	}
    }
    defaultproperties
    {
            HUDType=class'YourPackage.CustomHUD'
            bUseClassicHUD = true
            
    }
    Your minimap should now be displaying. However, in my case, the minimap seems to be either offset incorrectly or tiled wrong. (Same as daimaku).

  21. #21

    Default

    Quote Originally Posted by daimaku View Post
    any idea on why my floor texture is not drawing in the right way ?
    Open your content browser while the engine is loaded and find your M_minimap Material and double click it.



    On the bottom right you should find an interger at the beggining of the equition set to 0.5, change this to 1.0

    Cheers!
    Last edited by Vantto; 11-28-2012 at 08:46 PM.
    The only limitation is the one that you put upon yourself.

  22. #22
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,819
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    thanks for the info
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  23. #23
    God King
    Join Date
    Feb 2010
    Location
    Tegleg Records
    Posts
    4,377
    Gamer IDs

    Gamertag: tegleg digital

    Default

    anyone know how to draw/position other things along with this?
    if i add a crosshair that should appear centre screen it appears at the top left of the screen.
    eg
    Code:
    function DrawLivingHUD()
    {
        DrawMap();
        
        Canvas.SetPos(SizeX/2-32,SizeY/2-32); //centre screen
       Canvas.DrawTile(CursorTexture, 64 , 64, 126, 0, 128,128);
    its the same if i call DrawMap() after the crosshair

    thanks
    Code:
    We.spazmodicaly.simulate.new.sound.with.technical.equipment.that.is.specificaly.manufactured.for.humans.to.communicate.in.outer.space.Tegleg.manipulates.time.and.space.to.create.new.experiences.to.generate.a.hardcore.database.generation.
    LOOK>> Please ask questions in the forum, NOT a private message <<LOOK
    tegleg.co.uk
    My Tutorials n Stuff
    Games: NEW! Tegs Playground Multiplayer Edition
    Unwheel2 - VCTF Game - Sponic Mesh 3D
    Shh.. dont tell anyone about my android apps.
    will code for money

  24. #24
    The Sacrifice
    Join Date
    Dec 2009
    Location
    ArcadeKomodo.com
    Posts
    345

    Default

    Awesome Tutorial Guys. Perhaps we could make this the one-stop shop for compass creation. I desire to add a Horizontal Scrolling Compass to this tutorial. My initial strategy:
    1. Make a 3D Cylinder static mesh
    2. Texture Map with
    3. Attach the cylinder to the Camera

    Overkill? Perhaps an additional CustomHUD :: DrawHorizontalMap() Function could suffice, scrolling and wrapping the texture UV to HUD as needed. Features could include additional exec functions to adjust the texture clipping region (viewport) area width/height displayed on the HUD.

    Concept and Math
    This Image Was Automatically Resized by using the Screenshot Tag.  Click to view the full version

    Below are the modifications I made to the CustomHUD.uc and MU_Minimap.uc Class Files to implement a Horizontal Compass Quad Object/Material. I'll furnish the materials upon demand.

    Code:
    class CustomHUD extends UTHUD;
    
    var MU_Minimap GameMinimap;
    var float TileSize;
    var Int MapDim;
    var Int BoxSize;
    var color PlayerColors[2];
    
    var Int HorizontalCompassQuadWidth;
    var Int HorizontalCompassQuadHeight;
    var int HorizontalCompassTextureWidth;
    var int HorizontalCompassTextureHeight;
    var int HorizontalCompassTextureViewportWidth;
    var int HorizontalCompassTextureViewportHeight;    
    
    var float MPosXMap;
    var float MPosYMap;
    
    simulated function PostBeginPlay()
    {
        Super.PostBeginPlay();
    
        GameMinimap = MyGame(WorldInfo.Game).GameMinimap;
    }
    
    
    function DrawLivingHUD()
    {
        DrawMap();
        DrawHorizontalMap();
    
        MPosXMap = Canvas.OrgX + 30;
        MPosYMap = Canvas.ClipY/1.6;
    }
    
    
    /////////////////////////////////
    //Radar/Minimap
    /////////////////////////////////
    
    function float GetPlayerHeading()
    {
        local float PlayerHeading;
        local Rotator PlayerRotation;
        local Vector v;
    
        PlayerRotation.Yaw = PlayerOwner.Pawn.Rotation.Yaw;
        v = vector(PlayerRotation);
        PlayerHeading = GetHeadingAngle(v);
        PlayerHeading = UnwindHeading(PlayerHeading);
    
        while (PlayerHeading < 0)
            PlayerHeading += PI * 2.0f;
    
        return PlayerHeading;
    }
    
    
    function float GetPlayerDegreeHeading()
    {
        local float PlayerHeading;
    
        PlayerHeading = GetPlayerHeading();
        PlayerHeading *= RadToDeg;
    
        return PlayerHeading;
    }
    
    //There will be a warning on the screen
    //You can disable it, be typing "DisableAllScreenMessages"
    
    function DrawMap()
    {
        local float TrueNorth;
        local float PlayerHeading;
        local float MapRotation;
        local float ActualMapRange;
        local float CompassRotation;
        local Vector PlayerPos;
        local Vector ClampedPlayerPos;
        local Vector RotPlayerPos;
        local Vector DisplayPlayerPos;
        local Vector StartPos;
        local LinearColor MapOffset;
        local Controller C;
    
        //Set MapDim & BoxSize accounting for the current resolution
        MapPosition.X = MPosXMap;  //default.MapPosition.X * FullWidth;
        MapPosition.Y = MPosYMap;  //default.MapPosition.Y * FullHeight;
        MapDim = default.MapDim * ResolutionScale;
        BoxSize = default.BoxSize * ResolutionScale;
    
        //Calculate map range values
        ActualMapRange = FMax(    GameMinimap.MapRangeMax.X - GameMinimap.MapRangeMin.X,
                            GameMinimap.MapRangeMax.Y - GameMinimap.MapRangeMin.Y);
    
        //Calculate normalized player position
        PlayerPos.X = (PlayerOwner.Pawn.Location.Y - GameMinimap.MapCenter.Y) / ActualMapRange;
        PlayerPos.Y = (GameMinimap.MapCenter.X - PlayerOwner.Pawn.Location.X) / ActualMapRange;
    
        //Calculate clamped player position
        ClampedPlayerPos.X = FClamp(PlayerPos.X,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
        ClampedPlayerPos.Y = FClamp(PlayerPos.Y,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
    
        //Get north direction and player's heading
        TrueNorth = GameMinimap.GetRadianHeading();
        Playerheading = GetPlayerHeading();
    
        //Calculate rotation values
        if(GameMinimap.bForwardAlwaysUp)
        {
            MapRotation = PlayerHeading;
            CompassRotation = PlayerHeading - TrueNorth;
        }
        else
        {
            MapRotation = PlayerHeading - TrueNorth;
            CompassRotation = MapRotation;
        }
    
        //Calculate position for displaying the player in the map
        DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan2(PlayerPos.Y, PlayerPos.X) - MapRotation);
        DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan2(PlayerPos.Y, PlayerPos.X) - MapRotation);
    
        //Calculate player location after rotation
        RotPlayerPos.X = VSize(ClampedPlayerPos) * Cos( ATan2(ClampedPlayerPos.Y, ClampedPlayerPos.X) - MapRotation);
        RotPlayerPos.Y = VSize(ClampedPlayerPos) * Sin( ATan2(ClampedPlayerPos.Y, ClampedPlayerPos.X) - MapRotation);
    
        //Calculate upper left UV coordinate
        StartPos.X = FClamp(RotPlayerPos.X + (0.5 - (TileSize / 2.0)),0.0,1.0 - TileSize);
        StartPos.Y = FClamp(RotPlayerPos.Y + (0.5 - (TileSize / 2.0)),0.0,1.0 - TileSize);
        StartPos.X = FClamp(DisplayPlayerPos.X + (0.5 - (TileSize / 2.0)),TileSize/-2,1.0 - TileSize/2);
        StartPos.Y = FClamp(DisplayPlayerPos.Y + (0.5 - (TileSize / 2.0)),TileSize/-2,1.0 - TileSize/2);
    
        //Calculate texture panning for alpha
        MapOffset.R = FClamp(-1.0 * RotPlayerPos.X,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
        MapOffset.G = FClamp(-1.0 * RotPlayerPos.Y,-0.5 + (TileSize / 2.0),0.5 - (TileSize / 2.0));
        MapOffset.R = FClamp(-1.0 * DisplayPlayerPos.X,-0.5,0.5);
        MapOffset.G = FClamp(-1.0 * DisplayPlayerPos.Y,-0.5,0.5);
    
            //Set the material parameter values
        GameMinimap.Minimap.SetScalarParameterValue('MapRotation',MapRotation);
        GameMinimap.Minimap.SetScalarParameterValue('TileSize',TileSize);
        GameMinimap.Minimap.SetVectorParameterValue('MapOffset',MapOffset);
        GameMinimap.CompassOverlay.SetScalarParameterValue('CompassRotation',CompassRotation);
    
        //Draw the map
        Canvas.SetPos(MapPosition.X,MapPosition.Y);
        Canvas.DrawMaterialTile(GameMinimap.Minimap,MapDim,MapDim,StartPos.X,StartPos.Y,TileSize,TileSize);
    
        //Draw the player's location
        Canvas.SetPos(    MapPosition.X + MapDim * (((DisplayPlayerPos.X + 0.5) - StartPos.X) / TileSize) - (BoxSize / 2),
                    MapPosition.Y + MapDim * (((DisplayPlayerPos.Y + 0.5) - StartPos.Y) / TileSize) - (BoxSize / 2));
        Canvas.SetDrawColor(
            PlayerColors[0].R,
            PlayerColors[0].G,
            PlayerColors[0].B,
            PlayerColors[0].A
            );
            
        Canvas.DrawBox(BoxSize,BoxSize);
    
        /*****************************
        *  Draw Other Players
        *****************************/
        foreach WorldInfo.AllControllers(class'Controller',C)
        {
            if(PlayerController(C) != PlayerOwner)
            {
                //Calculate normalized player position
                PlayerPos.Y = (GameMinimap.MapCenter.X - C.Pawn.Location.X) / ActualMapRange;
                PlayerPos.X = (C.Pawn.Location.Y - GameMinimap.MapCenter.Y) / ActualMapRange;
    
                //Calculate position for displaying the player in the map
                DisplayPlayerPos.X = VSize(PlayerPos) * Cos( ATan(PlayerPos.X) - MapRotation);
                DisplayPlayerPos.Y = VSize(PlayerPos) * Sin( ATan(PlayerPos.Y) - MapRotation);
    
                if(VSize(DisplayPlayerPos - RotPlayerPos) <= ((TileSize / 2.0) - (TileSize * Sqrt(2 * Square(BoxSize / 2)) / MapDim)))
                {
                    //Draw the player's location
                    Canvas.SetPos(    MapPosition.X + MapDim * (((DisplayPlayerPos.X + 0.5) - StartPos.X) / TileSize) - (BoxSize / 2),
                                MapPosition.Y + MapDim * (((DisplayPlayerPos.Y + 0.5) - StartPos.Y) / TileSize) - (BoxSize / 2));
                    Canvas.SetDrawColor(PlayerColors[1].R,
                                    PlayerColors[1].G,
                                    PlayerColors[1].B,
                                    PlayerColors[1].A);
                    Canvas.DrawBox(BoxSize,BoxSize);
                }
            }
        }
    
        //Draw the compass overlay
        Canvas.SetPos(MapPosition.X,MapPosition.Y);
        Canvas.DrawMaterialTile(GameMinimap.CompassOverlay,MapDim,MapDim,0.0,0.0,1.0,1.0);
    }
    
    //There will be a warning on the screen
    //You can disable it, be typing "DisableAllScreenMessages"
    //DrawHorizontalMap by Techlord
    function DrawHorizontalMap()
    {
        //local float TrueNorth;
        local float PlayerHeading;
        local float HorizontalCompassTexturePixelScrollUnit;
        local float HorizontalCompassTextureScroll;
        local float HorizontalCompassTextureUUnit;
        local float HorizontalCompassTextureViewportU;
        local float HorizontalCompassTextureViewportV;
        local float HorizontalCompassTextureViewportUL;
        local float HorizontalCompassTextureViewportVL;    
    
        //Set MapDim & BoxSize accounting for the current resolution
        MapPosition.X = MPosXMap;  //default.MapPosition.X * FullWidth;
        MapPosition.Y = MPosYMap;  //default.MapPosition.Y * FullHeight;
        
        HorizontalCompassTexturePixelScrollUnit = default.HorizontalCompassTextureWidth/360;
        HorizontalCompassTextureUUnit = 1.0f/default.HorizontalCompassTextureWidth;
        HorizontalCompassQuadWidth = default.HorizontalCompassQuadWidth;
        HorizontalCompassQuadHeight = default.HorizontalCompassQuadHeight;    
    
        //Get north direction and player's heading, True North is CompassActor.Yaw = 0.0
        //TrueNorth = GameMinimap.GetRadianHeading();
        PlayerHeading = GetPlayerDegreeHeading();
        HorizontalCompassTextureScroll = PlayerHeading * HorizontalCompassTexturePixelScrollUnit;
            
            //Set the material parameter values
        //GameMinimap.HorizontalCompassOverlay.SetScalarParameterValue('CompassRotation',CompassRotation);
    
        //Draw the compass overlay
        Canvas.SetPos(MapPosition.X,MapPosition.Y - HorizontalCompassQuadHeight);
        
        /*
        DrawMaterialTile [Mat] [XL] [YL] [U] [V] [UL] [VL] [LColor] [ClipTile] [Blend] - Draws a material to an axis-aligned quad at the current drawing position (CurX,CurY).
            Mat - The Material to draw.
            [XL/YL] - The width and height of the tile to be drawn.
            [U/V] - The horizontal and vertical coordinates of the upper left corner of the portion of the material to be drawn. This value is a percentage in the range [0,1].
            [UL/VL] - The width and height of the portion of the texture to be drawn. This value is a percentage in the range [0,1].
            LColor - The color used to tint the tile.
            ClipTile - If TRUE, the tile should be clipped by the clipping region. 
        */
            
        //Calculate Scroll Viewport U/V
        HorizontalCompassTextureViewportU = (HorizontalCompassTextureScroll - (default.HorizontalCompassTextureViewportWidth/2)) * HorizontalCompassTextureUUnit; 
        HorizontalCompassTextureViewportV = 0.0f;
            
        //Calculate Scroll Viewport UL/VL    
        HorizontalCompassTextureViewportUL = default.HorizontalCompassTextureViewportWidth * HorizontalCompassTextureUUnit;
        HorizontalCompassTextureViewportVL = 1.0f;
        
        //`log("GetPlayerDegreeHeading="$PlayerHeading$",HorizontalCompassTextureScroll="$HorizontalCompassTextureScroll$",HorizontalCompassTextureViewportU="$HorizontalCompassTextureViewportU);
    
        //Outline Box
        Canvas.SetDrawColor( PlayerColors[1].R, PlayerColors[1].G, PlayerColors[1].B, PlayerColors[1].A );
        Canvas.DrawBox(HorizontalCompassQuadWidth, HorizontalCompassQuadHeight);
        
        //HorizontalCompassOverlay
        Canvas.DrawMaterialTile(GameMinimap.HorizontalCompassOverlay, HorizontalCompassQuadWidth, HorizontalCompassQuadHeight, HorizontalCompassTextureViewportU, HorizontalCompassTextureViewportV, HorizontalCompassTextureViewportUL, HorizontalCompassTextureViewportVL);
    }
    
    
    exec function ChangeMapsize(int size)
    {
       MapDim = size;
    
    }
    
    exec function MapSizeUp()
    {
        MapDim *= 2;
        BoxSize *= 2;
    }
    
    exec function MapSizeDown()
    {
        MapDim /= 2;
        BoxSize /= 2;
    }
    
    exec function MapZoomIn()
    {
        TileSize = 1.0 / FClamp(int((1.0 / TileSize) + 1.0) + 0.5,1.5,10.5);
        TileSize = 1.0 / FClamp(int((1.0 / TileSize) + 1.0) + 0.5,1.5,10.5);
    
    }
    
    exec function MapZoomOut()
    {
        TileSize = 1.0 / FClamp(Int((1.0 / TileSize) - 1.0) + 0.5,1.5,10.5);
    }
    
    
    defaultproperties
    {
            MapDim=256
        BoxSize=12
        PlayerColors(0)=(R=255,G=255,B=255,A=255)
        PlayerColors(1)=(R=96,G=255,B=96,A=255)
        TileSize=1
        MapPosition=(X=0.000000,Y=0.000000)
        
        //Horizontal Compass
        HorizontalCompassTextureWidth=2048
        HorizontalCompassTextureHeight=64
        HorizontalCompassTextureViewportWidth=256
        HorizontalCompassTextureViewportHeight=64    
        HorizontalCompassQuadWidth=256
        HorizontalCompassQuadHeight=64
        
    }
    Code:
    class MU_Minimap extends Compass;
    
    var Vector2D MapRangeMin;
    var Vector2D MapRangeMax;
    var Vector2D MapCenter;
    
    var() MaterialInstanceConstant Minimap;
    var() MaterialInstanceConstant CompassOverlay;
    var() MaterialInstanceConstant HorizontalCompassOverlay;
    var() Bool bForwardAlwaysUp;
    var() Const EditConst DrawSphereComponent MapExtentsComponent;
    
    function PostBeginPlay()
    {
        Super.PostBeginPlay();
    
        MapCenter.X = Location.X;
        MapCenter.Y = Location.Y;
        MapRangeMin.X = MapCenter.X - MapExtentsComponent.SphereRadius;
        MapRangeMax.X = MapCenter.X + MapExtentsComponent.SphereRadius;
        MapRangeMin.Y = MapCenter.Y - MapExtentsComponent.SphereRadius;
        MapRangeMax.Y = MapCenter.Y + MapExtentsComponent.SphereRadius;
    }
    
    defaultproperties
    {
        Begin Object Class=DrawSphereComponent Name=DrawSphere0
                 SphereColor=(B=0,G=255,R=0,A=255)
                 SphereRadius=5000.000000
        End Object
        MapExtentsComponent=DrawSphere0
        Components.Add(DrawSphere0)
    
        bForwardAlwaysUp=True
        Minimap=MaterialInstanceConstant'CompassContent.MIC_minimap'
        CompassOverlay=MaterialInstanceConstant'CompassContent.MIC_compass'
        HorizontalCompassOverlay=MaterialInstanceConstant'CompassContent.MIC_horizontalcompass'
    }
    Result:


    If you have a better function to handle this task, please share. Thanks for reading.
    Last edited by TechLord; 10-05-2013 at 02:32 PM.
    UMECHS Compendium
    Catalog of Modular 3D Entities

  25. #25
    The Sacrifice
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    288

    Default

    Hi, I can't download the marco6453's packages. Can someone send to me?
    milanezarts@gmail.com
    Last edited by Humberto Milanez; 03-17-2014 at 10:30 AM.
    Remember: One day you was a noobie too.
    "I not won every time I fought, but I lost all the times that I did not fight."

    [TUTORIAL]A simple way to replicate your custom animations to all clients


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.