Monday, 22 July 2013

MonoDevelop and Perforce - multiple save prompts issue

I thought it best to add a Perforce version control server to my files.
I am regretting rushing headlong in to this.

Downside/issue/bug - possibly just for Macs..
I am getting THREE 'are your really sure you want to save' prompts after ever edit on every document. And I cannot okay these with keyboard alone.

I don't have a fix, but my current attempted solution is to stop using Perforce... which doesn't seem to work. I am still prompted to save each item. Three times.

Solution - to stop the prompts from occurring ever more

After a bit of trial and error I've devised an approach. Sadly this involves not using Perforce. (I will later try and get this working, but for now, here's a way out).


  1. In MonoDevelop choose to compile. This is resulting in the 'Save (file) as...' dialog appearing -- the issue which I want to suppress. 
  2. Delete the original file via the file system
  3. Click 'Save' to the dialog in (1)
Voila. Dialog stops appearing on every single save. 


Calculating the angle or Quaternion between two points

So I have two sprites and I want one to face the other in a creepy Mona-Lisa-eyes-following kinda way. Just in case I fail to edit this correctly at a later stage, I should mention that I'm m  aking a 2D game, and so I'm actually only interested in rotation around a single axis. 

To do this I...

As input we have the position of two sprites in 3D space, AnnoyingSpriteFacingMe and Player.

The Quaternions is how Unity stores rotations, and so it is with these that we play.

Some code. In this example I am calculating the angle which the attacking boat should be on in 2D space in order to fire its cannons at the other boat.


public Quaternion desirableAngleForFiring(Vector3 attackingBoat, Vector3 defendingBoat){
// from a from and a to calculate the angle, then add 90
Vector3 targetDir = defendingBoat - attackingBoat;
float angle = (float) Mathf.Atan2(targetDir.x, targetDir.z) * Mathf.Rad2Deg;;
return Quaternion.Euler(0, angle+90, 0);
}