[Solved] Pointing at an object that's out of sight
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: [Solved] Pointing at an object that's out of sight
But (t==t) is always true.
Re: [Solved] Pointing at an object that's out of sight
@pgimeno it's not pickiness xD , it's an important pointer.
That point-slope code has special cases for when the player and enemy are perfectly aligned on the X or Y axes (so this prevents a division by zero, or when the slope 'm' results in zero itself), but for the case you mentioned of the player being at/beyond the screen borders, I think you could solve it by making the intersection point the player's position already.
So when the player is at or beyond the screen edges, the arrow position should equal that of the player's. But this shouldn't happen in practice I think -- a game like Super Smash Brothers that has this kind of feature seems to consider the ray origin as the center of the screen. Here you can see that magnifying glass bubble for when a character is off-screen:
That point-slope code has special cases for when the player and enemy are perfectly aligned on the X or Y axes (so this prevents a division by zero, or when the slope 'm' results in zero itself), but for the case you mentioned of the player being at/beyond the screen borders, I think you could solve it by making the intersection point the player's position already.
So when the player is at or beyond the screen edges, the arrow position should equal that of the player's. But this shouldn't happen in practice I think -- a game like Super Smash Brothers that has this kind of feature seems to consider the ray origin as the center of the screen. Here you can see that magnifying glass bubble for when a character is off-screen:
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: [Solved] Pointing at an object that's out of sight
Not for NaN values; those are the only ones where x==x is false.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- Gunroar:Cannon()
- Party member
- Posts: 1088
- Joined: Thu Dec 10, 2020 1:57 am
Re: [Solved] Pointing at an object that's out of sight
what does NaN mean ?
By the way, with that whole t==t thing I did my own rough fix through trail and error before pgmeno posted his fix when I saw things getting buggy.
By the way, with that whole t==t thing I did my own rough fix through trail and error before pgmeno posted his fix when I saw things getting buggy.
Re: [Solved] Pointing at an object that's out of sight
NaN means Not a Number. You get those in a few situations; dividing 0/0 is probably the most common. Checking for NaN with t == t saves adding guards for division by zero in my code. The case nonzero/0 gives infinity, and that is already handled properly because it won't pass the test for being the smallest.
Who is online
Users browsing this forum: No registered users and 206 guests