Page 1 of 1

Help - LUA lines

Posted: Fri Aug 19, 2011 2:26 pm
by Dman49
I am trying to figure out how I can use vector lines. What I want to do is have a line (which you can't see) go from the center of one image to the center of another. I then want this line to detect if there is anything in the way of this line. I'll have 1 image attack another, and I want to be able to have it tell if there is a wall or block in the way of his attack.

If anyone can help it would be much appreciated.

Re: Help - LUA lines

Posted: Sun Aug 21, 2011 7:40 pm
by Zasisem
Dman49 wrote:I'll have 1 image attack another, and I want to be able to have it tell if there is a wall or block in the way of his attack.
For this I'm sure I can help you, can you give a bit more detail?

Re: Help - LUA lines

Posted: Sun Aug 21, 2011 11:48 pm
by cmbeke
you need to find the equation of the line, and then check for any intersections with walls on any point of the line. check out this for info on how to get the equation of a line with two points, http://www.purplemath.com/modules/strtlneq.htm

Re: Help - LUA lines

Posted: Mon Aug 22, 2011 2:42 pm
by Dman49
Zasisem wrote:
Dman49 wrote:I'll have 1 image attack another, and I want to be able to have it tell if there is a wall or block in the way of his attack.
For this I'm sure I can help you, can you give a bit more detail?
I have a grid. two players are on 2 spaces. One of them needs to be able to see the other if he can attack it. I wan't to know if his field of vision to the other player is blocked by a wall or obstruction. So I need to form 1 line from the middle of one player to the middle of the other.

Re: Help - LUA lines

Posted: Wed Nov 22, 2017 4:36 pm
by DianeMarx
Thank everyone. I like to visit your forum and find answers to my questions.