## [Solved] Pointing at an object that's out of sight

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
darkfrei
Party member
Posts: 174
Joined: Sat Feb 08, 2020 11:09 pm

### Re: [Solved] Pointing at an object that's out of sight

But (t==t) is always true.
RNavega
Citizen
Posts: 69
Joined: Sun Aug 16, 2020 1:28 pm

### 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:

zorg
Party member
Posts: 3077
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: [Solved] Pointing at an object that's out of sight

darkfrei wrote: Sat Jan 09, 2021 8:55 pm But (t==t) is always true.
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: 219
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.
me: I don't always code but when I do it's done flawlessly.
also me:

Code: Select all

 function Gunroar:Cannon()
for x, enemy in ipairs(self.allEnemies) do
self:Cannon(enemy)
end
end

Code: Select all

Lua Error: [file Gunroar.lua]:18: C stack overflow

pgimeno
Party member
Posts: 2572
Joined: Sun Oct 18, 2015 2:58 pm

### 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 7 guests