PDA

View Full Version : Minimap tutorial issues.. Please help!



nikolajp
04-14-2010, 07:31 AM
I have been reading this tutorial about a minimap.
http://udn.epicgames.com/Three/MasteringUnrealScriptInterfaces.html

I got it working quite well.
Except for the alignment of the background image on the map.

I traced the tutorial through again, and found something that doesn't make sense. I hope you can help me.

It states (to calculate the center):

7. In order to track the player’s position in the map and convert it to a position in the map texture, we need to know the range of world space coordinates in the X- and Y-axes that is covered by the map texture. Two Vector2D variables will hold these values.

var Vector2D MapRangeMin;
var Vector2D MapRangeMax;

And the code for postbegin play is then..

function PostBeginPlay()
{
Super.PostBeginPlay();

MapCenter.X = MapRangeMin.X + ((MapRangeMax.X - MapRangeMin.X) / 2);
MapCenter.Y = MapRangeMin.Y + ((MapRangeMax.Y - MapRangeMin.Y) / 2);

MapRangeMin.X = MapCenter.X - MapExtentsComponent.SphereRadius;
MapRangeMax.X = MapCenter.X + MapExtentsComponent.SphereRadius;
MapRangeMin.Y = MapCenter.Y - MapExtentsComponent.SphereRadius;
MapRangeMax.Y = MapCenter.Y + MapExtentsComponent.SphereRadius;
}

But MapRangeMax/Min is not set anywhere calculating MapCenter - I checked and its 0,0. And afterwards the MapRangeMin/Max is calculated using the MapCenter?! It doesn't make sense for me.

I tried to find a function that returns the level X/Y, but could not find it.

Anyone see the logic?

.nikolaj

nikolajp
04-14-2010, 07:32 AM
BTW I found a solution for the error when manipulating the material in the package. It works in UDK before January, but later it spams the log and a text on the screen informs that it is not wise.

I use a copy of the material INST instead:

Declare them first:

var() MaterialInstanceConstant Minimap;
var() MaterialInstanceConstant CompassOverlay;

var() MaterialInstanceConstant MinimapCopy;
var() MaterialInstanceConstant CompassOverlayCopy;

The postbegin is this:

function PostBeginPlay()
{
Super.PostBeginPlay();

// create copy of material insts, because we want to manipulate it, and not mess with the package
MinimapCopy = new class'MaterialInstanceConstant';
MinimapCopy.SetParent(Minimap);
CompassOverlayCopy = new class'MaterialInstanceConstant';
CompassOverlayCopy.SetParent(CompassOverlay);

MapCenter.X = MapRangeMin.X + ((MapRangeMax.X - MapRangeMin.X) / 2);
MapCenter.Y = MapRangeMin.Y + ((MapRangeMax.Y - MapRangeMin.Y) / 2);

MapRangeMin.X = MapCenter.X - MapExtentsComponent.SphereRadius;
MapRangeMax.X = MapCenter.X + MapExtentsComponent.SphereRadius;
MapRangeMin.Y = MapCenter.Y - MapExtentsComponent.SphereRadius;
MapRangeMax.Y = MapCenter.Y + MapExtentsComponent.SphereRadius;
}