Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Craftomega · Apr 02, 2015 at 05:32 PM · c#circle

How Do You Create a Custom Radial Object or Particle?

OK, I have been looking into this for a week and for the life of me I can’t find a good answer. What I want to do is from a fixed point create a circle with a custom radius. Here is the problem; I have to be able to control how much of the circle is created. And I would have to be able to script it to react to things on the point of collision.

EX1: From the front of a space ship a shield is projected that only covers 90 degrees of a circle.

EX2: A mage casts a spell that starts to create a circle on a wall but gets interrupted; making it so it only creates a percentage of a circle based on how long he spent.

Part of the problem is, is that I am not too sure what would be most effective for this, that’s why I left it vague. I can work with most kinds of coding and unity variables. So ultimately the answer would be whatever is most effective.

But if I had to give answer it would be: a curved line segment, the collection grows with the arc size, a filled mesh in that would be in the shape of a piece of pizza. With cords at 3 points, the center point of the circle then at the ends of the arcs.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlwaysSunny · Apr 02, 2015 at 05:32 PM 2
Share

The word "circle" doesn't convey enough information.

The answer depends on what form of data you want, and that depends on what you want to ultimately accomplish.

A sequential collection of points describing a curved line segment? Should the collection have a fixed number of points, or grow with the arc size? Do you want to end up with a filled mesh? (methinks you do, since you want collision against the arc) In what way should the mesh be closed? Radially like a sliced pizza? With a chord between the two ends of the arc?

You must better define your parameters to receive help. All of these things and more can be done, but the approach for each desired outcome will be quite different.

avatar image Craftomega · Apr 02, 2015 at 08:24 PM 0
Share

Part of the problem is, is that I am not too sure what would be most effective for this, that’s why I left it vague. I can work with most kinds of coding and unity variables. So ultimately the answer would be whatever is most effective.

But if I had to give answer it would be: a curved line segment, the collection grows with the arc size, a filled mesh in that would be in the shape of a piece of pizza. With cords at 3 points, the center point of the circle then at the ends of the arcs.

avatar image JedBeryll · Apr 02, 2015 at 08:49 PM 0
Share

$$anonymous$$y program needs something similar i don't know if it works but i was thinking of connecting some line renderers. Then i just need a fix point, a radius and increase the rotation (x) when creating the spline positions. Anyone thinks it's a good idea?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AlwaysSunny · Apr 02, 2015 at 08:43 PM

Please post non-answers as comments. Thanks,

Regardless of the resultant format, at some point or another, you'll want an algorithm that can take a radius, direction, and a percentage (of a circle), and return a mesh or whatever you want. For instance, for a 90 degree arc 5 units in front of an object, you'd be able to ask for

Mesh mesh = GenerateArcMesh( 5f, transform.forward, 0.25f );

Optionally you could have a parameter to achieve different vertex densities for finer control over cost vs accuracy, code which assigns UVs to the mesh so you can texture it, etc. Or alternate methods which accept two angles and form an acute or obtuse arc between them. If you can write it, you can have it.

Find two angles which describe the arc shape. These will be two angles you find by going CW and CCW from the forward direction. The angular sweep amount will be informed by the "percentage" argument. (if 25%, these will be 45 and -45 degrees from the forward direction).

Decide how many total points are involved based on desired point density. This can be accomplished by a verts-per-angle variable; something like 1 vert per 5 or 10 degrees sounds reasonable.

In a loop whose iterations are defined by the desired vertex density, sweep the arc defined by the two angles at whatever radius, putting each discovered point in a collection.

You'll somehow have to arrive at triangles which create a solid shape; the easiest way would be creating a new triangle (think thin pizza slice) between the circle origin and each two verts you find in "sweep" loop.

It's going to be a little tricky if you have no prior experience with building meshes or performing this kind of mathematical operation, but it's definitely do-able. Trial by fire, right?

Unity Mesh API reference

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Craftomega · Apr 02, 2015 at 09:58 PM 0
Share

Thanks this should get me started. Ill post back if I manage to make something that works.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Drawing a Circle instead of Rect 1 Answer

Position Objects around point[With picture] 0 Answers

Having trouble with implementing circular player movement 1 Answer

Determine Rotation Between Two Points 2 Answers

Prevent Object from going out of Circle Radius 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges