C3: Visualizing Line of Sight angles and distance.

3

Stats

3,411 visits, 4,812 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 19 Mar, 2018. Last updated 19 Feb, 2019

Line of Sight (LOS) - What can it see?

In an effort to help me 'see' what LOS was seeing, I put together a simple project that shows what is seen and when.

If you need it, you should be able to pull out the line code for use in your own project.

(A link to a C3 project is at the end of the tutorial)

For C2 owners

I've included a screen shot of the events so you can duplicate the project.

The objects are sprites unless self explanatory. The PM sprite requires the Line Of Sight behaviour, and the project will require the Keyboard behaviour for the key presses.

You can edit the parameters of the Line Of Sight behaviour to see how it changes.

While this example doesn't have solid sprites in the way, you can add them and would be able to see the 'cone' used and whether you can see the target sprite.

If you move around the screen, you can adjust the angles to see how it affects the result.

What it does

This project places two lines at the same angle as the PM sprite. (Their image point is changes in an attempt to have the lines start at the sprite we are doing the LOS from).

The length of the lines is set to the RANGE of the LOS behaviour. (This isn't indicative of how far you can see since they are at an angle. The LineRange is set at the actual range from the source sprite + the range of the LOS. This shows how far you can see. If you can imaging this in a maze, it would show you what is outside of the LOS.

The range line is a bit finicky when you start rotating the sprite, but I didn't want to complicate the events to demonstrate the process.

The end result.

When you run it, you should see something like this...

Solids

If you would like to see how solids affect the LOS, insert a new sprite (Call it 'Wall') and make it a small rectangle. Place it between the PM sprite and the NME. Give the wall sprite the SOLID behaviour.

Add the following events and you can then toggle the wall with the space bar.

I hope this was somewhat helpful for you!

C3 Project File.

The C3 project file is available HERE.

  • 0 Comments

Want to leave a comment? Login or Register an account!