[Kind of closed] "Line of sight"

For questions about using Classic.

Post » Fri Sep 09, 2011 3:14 pm

>tulamide
Just curious, any reason why you used 'move at angle' for the player instead of a behavior?
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Fri Sep 09, 2011 3:29 pm

>Nifl
You can't do it with the LOS behavior, can't test two instances of an object for LOS, pity. I've had similar problem while playing with a path movement. I think, you'll have to create your own LOS - haven't checked if you could use Jayjay's example for it.Noga2011-09-09 15:31:29
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Fri Sep 09, 2011 5:37 pm

This can be done with my cap Nifl, just have a private variable to say what mode the wall/enemy is in. Then only set the enemy to "NOLOS" when the object LOSCheck overlaps is in "WALL" mode.

Edit: Just saw that you already have a "DEAD" state. Just use that variable to choose if the object blocks others or now.

As for the lag with 100 objects, I'm not sure what's going on there, as I get over 200 fps with around 200 BadGuy objects while also running the debugger. Can I see the events you're using?Jayjay2011-09-09 17:46:18
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Sat Sep 10, 2011 2:02 pm

[QUOTE=Noga] >tulamide
Just curious, any reason why you used 'move at angle' for the player instead of a behavior?[/QUOTE] No particular reason. I'm just used to do it this way if I'm in a hurry. The cap was a quick&dirty product :)

[QUOTE=Nifl]
Now this, you solved if I were to have another object blocking the vision but the problem is that I need to know:
Is any "Wall&EnemySprite" blocking the line of sight to any other "wall&EnemySprite"?
That is:
What "Wall&EnemySprite"s can the "PlayerSprite" see, and what "Wall&EnemySprite is blocked by other "Wall&EnemySprite"s?.

I don't know how well I explained it, but I really only have 2 "Active objects" in the game; a PlayerSprite and a sprite representing enemies AND obstacles. (And I need it that way, as walls need to change to enemies and vise verse in my game)[/QUOTE] This is what I mean by "think too complicated".
For every game there comes a time when you have to optimize your code/thoughts. Even the biggest game developers wouldn't be able to constantly check roughly 1 million times per tick without dramatically slowing down their game. So it is about tricking. Like in 3D games high poly models are exchanged by low poly ones when they are displayed far away.
1) You don't need to test all instances. Limit the tests to the range that your player sprite will "see".
2) Don't loop 360 times to get a full circle. Instead create one circle sprite and set it to the radius you want the player to be able to see. Select all blocks that overlap that sprite (Or use no object at all and select those blocks with math only). Now loop through those blocks and check with sample points every blocksize against the angle to the player sprite if there are other blocks in the way. If so, set it to invisible, else set it to visible.

This should speed up a lot. I didn't have a look at JayJay's cap. Maybe it is exactly doing so. If not, I might do a cap, if I find the time.tulamide2011-09-10 14:03:14
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Sep 13, 2011 12:13 pm

Well, thanks for taking the time everyone, (Have been afk over 9/11). I greatly appreciate your thought about and knowledge into the subject. I'm going to create a secondary object to test for line of sight now. Lets see how that pans out. If it doesn't work, well then I'll probably deal with this at a later time. It is taking to much of my creation time at the moment. Thank again everyone :]
B
6
S
1
G
2
Posts: 22
Reputation: 719

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests