- Home /
Mini Map Help
Hey guys. Me again. I am creating this game and I implemented a mini map. It uses a separate camera to go around the map and it follows the main camera. Only problem is, is that when I move or turn my character around, it rotates the map instead of the little character texture. Does anyone know how I can get just the texture to move instead of the whole map? Like a COD Style kinda. Thanks to anyone who helps!
Can't tell you for sure what it is cos I don't know how your scene is set up. Is your main camera attached to your player? $$anonymous$$oving the player moves the main camera which moves your $$anonymous$$i map camera?
Answer by wibble82 · Mar 06, 2014 at 08:42 PM
I suspect the issue is that your camera is a child of your player object? So whenever the player moves, the camera moves with them.
You could fix this 2 ways:
make your camera NOT a child of the player, and each frame set its position to be player.transform.position + some offset
keep your camera a child of the player, and each frame set its rotation to be a fixed value (probably [90,0,0] if you want it looking down?)
I'd favour the former option, as attaching the camera to the player will give you more headaches down the line (such as player death = camera death!), and won't allow you to do funky effects like smoothing on camera movement and the like!
Could you help me out with that? Heres the $$anonymous$$imap code: (Javascript) Im new at this.
@script ExecuteInEdit$$anonymous$$ode()
enum posOnScreen { TopLeft, BottomLeft}
var placement : posOnScreen = posOnScreen.TopLeft;
var $$anonymous$$imapSize : float = 2.0;
var offsetX : float = 10.0;
var offsetY : float = 10.0;
private var adjustSize : float = 0.0;
var borderTexture : Texture;
var effectTexture : Texture;
var $$anonymous$$imapCamera : Camera;
function Update() {
if ($$anonymous$$imapCamera == null) return;
adjustSize = $$anonymous$$athf.RoundToInt(Screen.width/10);
if(placement == posOnScreen.TopLeft){
$$anonymous$$imapCamera.pixelRect = new Rect(offsetX, (Screen.height -($$anonymous$$imapSize * adjustSize)) - offsetY, $$anonymous$$imapSize * adjustSize, $$anonymous$$imapSize * adjustSize);
} else if(placement == posOnScreen.BottomLeft){
$$anonymous$$imapCamera.pixelRect = new Rect(offsetX, offsetY, $$anonymous$$imapSize * adjustSize, $$anonymous$$imapSize * adjustSize);
}
}
function OnGUI(){
if(borderTexture != null){
$$anonymous$$imapCamera.Render ();
if(placement == posOnScreen.TopLeft){
GUI.DrawTexture(Rect(offsetX, offsetY, $$anonymous$$imapSize * adjustSize, $$anonymous$$imapSize * adjustSize), effectTexture);
GUI.DrawTexture(Rect(offsetX, offsetY, $$anonymous$$imapSize * adjustSize, $$anonymous$$imapSize * adjustSize), borderTexture);
}
if(placement == posOnScreen.BottomLeft){
GUI.DrawTexture(Rect(offsetX, (Screen.height -($$anonymous$$imapSize * adjustSize)) - offsetY, $$anonymous$$imapSize * adjustSize, $$anonymous$$imapSize * adjustSize), effectTexture);
GUI.DrawTexture(Rect(offsetX, (Screen.height -($$anonymous$$imapSize * adjustSize)) - offsetY, $$anonymous$$imapSize * adjustSize, $$anonymous$$imapSize * adjustSize), borderTexture);
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613135547im_/https://answers.unity.com/themes/thub/images/avi.jpg)