• 13
• 18
• 19
• 27
• 9
• ### Similar Content

• Hi everyone! I'm currently working on a series of books about 2D Shader Development.

The idea is to synthesize a bunch of techniques that are specifically useful for 2D, even if they work on 3D as well.

I released the first book last week. It's 4.99 on Amazon or free on the series website, https://www.2dshaders.com

This is an independent initiative, I don't work for any publisher whatsoever. The contents of the books are the result of a 4-year span where I started teaching this in Argentina and USA, always making the workshop better. Now I'm expanding it to make more sense in book form.

I'd love to hear your opinions on the idea and if you get the book let me know what you think.

By the way, the examples are in Unity, but the concepts from the book should be easily transferable to any graphics api/engine.

Hope you like it!

• While looking out for that pesky Terrator, our little alien is doing a bit of relaxed mining down on the new gas planet "Lelantos" this weekend....

• I have a native iOS game (objective c, XCode build) which I am considering to port to other platforms.
Core gameplay is based on solely on geographical maps, and custom drawing over maps. It also has Core Data. This part is complete in development.
What is not done yet is: monetization, gamification (leaderboards, challenges) and multiplayer functionality.
As I think more about it, I am tempted to think if this is the right time to move to a cross platform tool such as Unity. But before dedicating time to port my 5 years side-project effort in Objective C, I really want to know if its worth it.
- Does Unity support such plugins / assets that will fulfill all my above requirements?
- Unity Personal seems to have only 20 concurrent users - is it too costly scaling if I decide for extending to web and android platforms?
- What is the general workflow involved in publishing to iOS, Android, PC, and web platforms while using Unity? I mean to ask about various points of signing stuff, paying fees and getting certified.
- How long will it really take to port my entire Objective C project into Unity? I am somewhat familiar with C# but I am finding it hard fidgeting with Unity IDE as lot of things are focused around FPS and 3D while my game is still 2d - not much action involved. I seem bit overwhelmed by the list of features I see there. All in all, I do not want to lose my momentum while still making sure its portable to everywhere.
- Any assets I could use (for free to try basis in debug) that are relevant for my game?
- Last but not the least, are there any costs that I need to be paying upfront to Unity, for using it (apart from their monthly subscription model)? I don't understand their costing for multiplayer in conjunction with their subscription fees - if someone could kindly elaborate.
• By GytisDev
Hello,
me and few friends are developing simple city building game with unity for a school project, think something like Banished but much simpler. I was tasked to create the path-finding for the game so I mostly followed this tutorial series up to episode 5. Then we created simple working system for cutting trees. The problem is that the path-finding is working like 90% of the time, then it get stuck randomly then there's clearly a way to the objective (tree). I tried looking for some pattern when it happens but can't find anything. So basically I need any tips for how I should approach this problem.
Use this image to visualize the problem.
• By aymen
please any know how can i' calculate the centroid from any number vertices

# Unity flash collision question

This topic is 3065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hola. Posted this in the web development section, but got no replies. Need an answer to get working on this game. Post: "I'm making a flash game with a lot of movieclips that need to register collisions. I need to know how I can get collisions to register off of just select pieces of visual data, or specify the bounding box for the movieclip some other way. Here's an example of what i mean. I have a turret, and each turret has a ranch, which is a circle around the turret. I want the turret to be a single object, but have the collision only be detected on the turret itself, not the circle. I'd like to just use the built in flash collision detection, but if rewriting collisions isn't out of the question. Just want to know if that's doable easily in flash. PS: Why doesn't flash have a built in Vector2D or Vector3D class?" Link: http://www.gamedev.net/community/forums/topic.asp?topic_id=551131

##### Share on other sites
hello

are you working on AS2 or AS3? I am assuming you are working on AS2

first if turrets are always in a circle, why don't you use two circle collision detection?

If you want to check collision detection on pixel level first you need to draw all objects to a bitmapdata. after that you should draw the object that you want to check for collision into another bitmapdata.

after that for each pixel in the second bitmap data you need to if it has > 0 alpha and pixel on the scene also has > 0 alpha. if both is true there is a collision

here is an example, I hope it will help you to understand what am I trying to say. my explanation sucks =)

swf file

I should mention that you will not be able to do much testing using this method. as2 is very slow, and even as3 will not work with high number of objects.

##### Share on other sites
there is no vector class in as2 and as3 (as far as I know, I didn't use as3 that much) but there is a point class but it is not that usefull

and it is in 2D. probably macromedia is never intented to make flash work on 3D =)

##### Share on other sites
Quote:
 Original post by shultayshelloare you working on AS2 or AS3? I am assuming you are working on AS2first if turrets are always in a circle, why don't you use two circle collision detection?If you want to check collision detection on pixel level first you need to draw all objects to a bitmapdata. after that you should draw the object that you want to check for collision into another bitmapdata.after that for each pixel in the second bitmap data you need to if it has > 0 alpha and pixel on the scene also has > 0 alpha. if both is true there is a collisionhere is an example, I hope it will help you to understand what am I trying to say. my explanation sucks =)swf fileI should mention that you will not be able to do much testing using this method. as2 is very slow, and even as3 will not work with high number of objects.

I'm working in AS3. Circle to Circle would work fine, but I'm guessing I'd have to make my own Collision system then yes?

##### Share on other sites
yes, it won't be that hard if you work on circles. good luck

##### Share on other sites
Quote:
 Original post by shultaysyes, it won't be that hard if you work on circles. good luck

Alrighty. That will work fine for the most part. Is there a way to get the bounding box for a movieclip (I have a large square movieclip that needs collision detection and a circle wouldn't work for this one) so I can do circle/square collision?

I think the way AS3 does it is just getting the bounds of the visible movieclip to make a bounding box anyways. Is there a way to get that bounding box so I might be able to do a mix of both?

##### Share on other sites
Heya, here's a crash course on circle and box collision

Circle vs Circle test:

1) get distance between the centers of each circle.
2) if the distance is less than the 2 radiuses added together, the circles have collided.

To make it more efficient, you can work with squared distances as appropriate to not have to do the square root operation.

Circle vs Box test (assuming the 2d box is an axis aligned bounding box aka AABB and that this is 2d):

1) Find the closest point on the box to the circle's center by doing the below:  a) X = CircleCenterX  b) if X less than BoxLeft then X = BoxLeft  c) else if X greater than BoxRight then X = BoxRight  d) Y = CircleCenterY  e) if Y less than BoxTop then Y = BoxTop  f) else if Y greater than BoxBottom then Y = BoxBottom2) Calculate the distance from the closest point on the box to the center of the circle.3) If the distance is less than the radius of the circle you have a collision.

And hopefully you can figure out box vs box test (:

Hope this helps!

##### Share on other sites
Quote:
 Original post by Atrix256Heya, here's a crash course on circle and box collision Circle vs Circle test:1) get distance between the centers of each circle.2) if the distance is less than the 2 radiuses added together, the circles have collided.To make it more efficient, you can work with squared distances as appropriate to not have to do the square root operation.Circle vs Box test (assuming the 2d box is an axis aligned bounding box aka AABB and that this is 2d):*** Source Snippet Removed ***And hopefully you can figure out box vs box test (:Hope this helps!

What do you mean by "To make it more efficient, you can work with squared distances as appropriate to not have to do the square root operation."

Where was the Square root Operation in Circle vs. Circle? or do you mean when you calculate the distance between the two points? sorry, your wording just confused me.

##### Share on other sites
yeah you got it...

for instance if you wanted to know if a point was inside a circle, you would do something like this...

Distance = sqrt(square(PointX-CircleX)+square(PointY-CircleY));

then if the radius was 10, you would say...

if(Distance < 10) there is a collision!

but if you "square both sides of the equation" you get this...

Distance = (square(PointX-CircleX)+square(PointY-CircleY));

if(Distance < 100) there is a collision!

it saves you the square root operation, which is nice.

if this is weird to you, get it working first with the square root in there, and then if you want to, you can optimize your test by getting it working without the square root.

##### Share on other sites
DisplayObject.getBounds(DisplayObject.stage) will get you the bounding box of the display object relative to the stage.

If you want rectangle to rectangle, use (NOTE: these are example variables) myBoundingBox.intersects(otherBoundingBox) to find whether they are intersecting.

Even better, you could skip a step and use DisplayObject.hitTestObject(obj:DisplayObject) to find whether their bounding boxes are intersecting.

If you want to have circle to circle collisions, just have a radius number in each object and do a distance check between each one.