I'm having a hard time getting my head around something here. I suck at explaining this, but I'm going to try never the less. This is not directly related to my problem, but might help me understand it or get closer to the solution. It might make me solve it.
I have value A and value B, both ranging from -6 to +6.
I'm looking for an equation preferably, or any other way like a set of conditions, to make Abs( A )+ Abs( B ) never equal more than 6. Using MMF2
OK i will try... Lets say
value A ranging from -6 to +6 is a vertical speed(in pixels), for moving forwards and backwards
value B ranging from -6 to +6 is a horizontal speed(in pixels), for moving left and right
And i want the maximum speed(pixels moved) to be 6.
But if you are going at, lets say, full speed forward and turn a full right or left; your speeds would now be A=6 B=6 or A=6 B=-6. Either way your total speed now is Abs( A ) plus Abs( B ), 6 plus 6 = 12(pixels moved). In this particular case A and B would logically be altered to A=3 B=3, by doing something.
Trying to put the 'solution' values into values C and D and not altering the original values A and B, seems like a right approach.
I think this is a bit clearer? i hope it is
Well, if that's your exact scenario, maybe do the classic Pythagoras theorem?
Speed = Sqrt( A^2 + B^2)
You get a positive number every time, and the player doesn't go twice as fast by moving diagonally.
What James or Sketchy said should work nicely, though.
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.
no muz but it still goes faster. as it should. i dont understand why it would need to be limited. this problems logic is, er, illogical.
i dont exactly get your logic? if you have a horizontal speed and vertical speed (speed by the way cannot be negative, you are thinking of velocity) logically when you add them together with vector math you ARE going to be going faster. why are you trying to make it slower? what exactly are you trying to accomplish, in real world terms please.
I agree. This problem is kind of odd. If you're trying to do some kind of 360° movement, you should use polar coordinates (use 2 variables: speed and angle) and then convert back to cartesian coordinates (x and y speed).
(edit: typo)
Edited by Hernan
This space is for rent
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
31st December, 2009 at 00:54:10 -
He's probably trying to combine them into one event for the 20 event compo.