Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Feb 2008
Offline Last Active Private

Posts I've Made

In Topic: A* script not returning the correct path

25 April 2016 - 04:41 PM

Ah darn that was the issue and it works now! Guess i know now to be more careful with stuff like that in C# ! Thanks guys :)

In Topic: A* script not returning the correct path

24 April 2016 - 01:00 PM

Your indenting is messed up, so it's hard to see the structure.

However, I seem to be missing a break or return.


When you pull the target node from the open set "if(currentNode == targetNode){" case

you walk backwards to get the path, reverse it, and then?


It looks to me that you loop back to get a new node from the open set.

Ah yeah good spot, i added a break but it still seems to infinite loop. Which seems to suggest current node never becomes target node.


I have edited the question to fix some indents i guess i'm the only one who likes that kind of indentation lol.

In Topic: A* script not returning the correct path

23 April 2016 - 09:34 PM

1. Step through the function with your debugger and check what it's doing. Have you set 'walkable' to true?

2. Make sure you come up with a better way of getting neighbors. That loop is going to have dramatically worse performance the larger your graph gets.


1) I dunno what i did but it seems to just infinite loop and crashes unity. But it seems that currentNode doesn't change to the next node. Would it help if i provided my Node class ?

2) I'll optimise when i have it working :P I might look into heap after but one step at a time!

After stepping through, it seems it just goes back and forth between nodes rather than progress forward. But i don't know why =/

In Topic: Draw only portions of the circle visible to the user

26 December 2015 - 11:21 PM

If your circles dont change significantly over time, and/or if you have many circles that look the same, draw the circle to an image and blit that to the screen, which should perform significantly better (you can update the image, even every frame if theres many circles sharing the same image and thus saving calculations).


I'm not sure if this is beneficial, given when zooming in and out because i would be basically drawing a huge circle to an image then drawing the image, i don't see how this will reduce processing time, as i am adding a step and still drawing the circle either way? Also, simply resizing the image will pixelate or make the perimeter line extremely thin when zoomed out far.

In Topic: Draw only portions of the circle visible to the user

23 December 2015 - 12:35 AM

Did you try just not drawing circles bigger than some X? While the image is obviously broken then, it should give you a big boost in performance if you are correct.

That is, you can do simple experiments to check your own conclusions, before going in and properly fix it.



So i decided to skip drawing circles above a certain size to test it, like you suggested, here is the results.


With the removal of large circles above x size:



Without removal of large circles:



Notice stroke() is painfully bad. Suggesting i need to skip drawing portions of circles not visible on screen to reduce the expensive process of stroke function.

This also tells me that if the circle is not visible on the screen, the browser still does a lot of processing for it, so it will probably be better to find a way to skip the function call entirely when the circle is not visible to the viewer's output with a simple math formula, assuming its simple and not going to be any more expensive. 

But a 600ms time for a single function is definitely too high.


I also added a basic JavaScript circle example to my original post.