Tuesday, April 22, 2014

Support: Circular Gravity Force

ALL SUPPORT MOVED TO THE UNITY FORMS

Version compatibility:
The project was built in 4.1.2, and works in 4.0.0 if you import from 4.1.2. Any lower versions and the demo Scenes will not import correctly because of metadata constraints. However the scripts work great with 3.5.0 and possibly lower.

12-01-14
Version 2.75 Released
-- Added big visual editor updates for the CircularGravity
-- Added CircularGravity Icons

04-22-13
Version 2.50 Released
-- Added 'Circular Gravity Force' tool under Tools->Circular Gravity Force.
-- Added 'Angle To Force' under Constraint Properties.
-- Added 'Angle To Force' to the CircularGravityVisualizer.
-- Updated properties so that they can be used to animate.
-- Updated all scripts to be in its own namespace.
-- Updated all scenes for the new changes.

01-02-13
Version 2.25 Released
-- Added Special Effects, allowing you to add Special Effects to objects effected by the Circular Gravity.
-- Added Time Effected to Special Effects, allowing you to set a time for the Special Effect.
-- Added Attached Game Object to Special Effects, allowing you to attach an effect in the form of a GameObject.
-- Added Physics Effect to Special Effects, allowing you to add a physics effect effected by the Circular Gravity.
-- Added CircularGravityGizmos class, allows you to see the CircularGravity in EditMode/Gizmos.
-- Added TimeScale class to CircularGravityVisualizer allows you to slow down time during a scene for fun.
-- Added Special Effects to the CircularGravityVisualizer.
-- Updated and changed Added Play Area scene to Performance Cube Test
-- Updated some shape performance issues.

12-01-13
Version 2.00 Released
-- Added Shapes to the properties, allowing you to pick between three different shapes sphere, capsule, or raycast.
-- Added ForcePoint, allows you to set where the force/gravity is in the shape area, rather than always being in the center. If not supplied, will default to center of the assigned GameObject.
-- Added ForcePoints, allows you to set multiple Force Points rather than just one.
-- Added CapsuleSize to the SizeProperties, only relevant when shape is a capsule.
-- Added to DrawGravityProperties now draws the appropriate shape sphere, capsule, or raycast.
-- Added to DrawGravityProperties now rotates with the assigned Gameobject.
-- Added Railgun scene.
-- Added Tractor Beam scene.
-- Added Invention scene.
-- Added Play Area scene to tutorials.
-- Updated CircularGravityVisualizer class to include v2.0 changes.
-- Updated all scenes to use the new v2.0 features.
-- Updated Maze scene to use the capsule shape.
-- Updated code for better performance.

09-18-13
Version 1.60 Released
-- Fixed Line Rendering material problem, sometimes hindering workable builds.
-- Added Material drawing the force area.
-- Added a new material look to the scenes.

06-07-13
Version 1.52 Released
-- Fixed a problem when dynamically creating CircularGracity object.

06-05-13
Version 1.51 Released
-- Added Draw Gravity Properties.

05-24-13
Version 1.50 Released
-- Added a big feature in 1.50 that allows you to shape the force to whatever form you want using triggers, giving you the ability to effect anything within or outside the trigger shape.
-- Added Vacuum Scene Demo Using Trigger.
-- Added Maze Scene Demo Using Triggers.
-- Added Tutorial Trigger scene.
-- Added MoveVacuum script.
-- CircualrGravityVisualizer now defaults start values based on what’s setup in the CircualrGravity correctly.
-- No Gravity now defaults based on what the Physics.Gravity is in the scene.
-- Fixed line rendering problem with Draw Gravity Force toggle.
-- Condensed LINQ code.

04-25-13
Version 1.20 Released
-- Properties have been cleaned up in the CircularGravity script, now better organized.
-- Added tag filtering options to the CircularGravity script.
-- Added property options for setting up slider min and max values within the CircularGravityVisualizer.
-- Added a tag filter scene tutorial.

04-19-13
Version 1.01 Released
-- Fixed input problem with up/down for Marble controls, you can now use the scrollwheel.

04-18-13 
Please feel free to leave any questions/comments regarding the Circular Gravity Force asset below. I will be posting version updates to this page as time moves on.

76 comments:

  1. Hey LaneMax. I want to create effect of "destroyable" wall of cube depended on mouse position. How you think, it will be enought easy for U3D newbie? (i know little 3D graphics and a little bit of programing).

    Amalia.
    info@androidtheme.pl

    ReplyDelete
  2. Hey Amalia,

    How I would approach it is creating an empty GameObject, relate the CircularGravity script to it, and use the Input.mousePosition vector to move that GameObject based on the mouse.

    This might give you a direction where to started: http://answers.unity3d.com/questions/12322/drag-gameobject-with-mouse.html

    ReplyDelete
  3. Hey Lane,

    Is there a way to easily change the shape of the gravity to make it cylindrical? This would be useful for making a vacuum tube or a fan pushing things without affecting objects behind it or beside it.

    Probably a whole different script as this one is "Circular" gravity, but I'm curious either way.

    ReplyDelete
    Replies
    1. Maybe later down the road I might start looking into other shapes, but for now its only circular.

      On another note, hoping by the end of the week ill have a new version up which will include the tag filtering, so keep an eye out for it.

      Delete
    2. Ok, cool. Well if you decide to do other shape functionality I'm definitely interested in them.

      Delete
    3. Hey Fox, so the tag filtering update just went through in 1.20, I also made some other property changes so be sure to save your old scripted if you've made changes to it.

      Delete
    4. Just tested it out, acting weird on my end. I used two cubes with different tags and whichever is filtered is getting the correct force applied but the other tags are getting the opposite amount of force.

      Also there looks like some runtime weirdness is going on as well. In the second part of this vid the green boxes way out of range just start flopping around for no reason. The cylinder is the only source of the script.

      http://www.youtube.com/watch?v=TOx3lu2fr0Q

      Delete
    5. hmmm that's interesting, do you know if its acting weird in the filter tutorial scene? I'll take a look at it on my end and get back with you. By the way cool hand

      Delete
    6. Nah it seems to be fine in the example scene. I'm not sure what could be different somewhere thats changing it.. I'll tinker some more with it.

      Delete
    7. Seems to be acting normal now. Might have just been confused since I imported it and used it during the same session. Doesn't act up after reloading unity. Sweet update now that its smooth I can reach in with PlayMaker and change this on the fly super easy.

      Delete
    8. Sweet good deal, let me know if you run into any problems.

      Delete
    9. Hey sup fox,

      So I'm happy to tell you I'm coming out with a new version that allows shapes. I'm pretty excited about it, seems like it’s working pretty well. I added the ability to assign a trigger to the gravity script, so that the gravity only effects what’s within or even outside of the trigger, this pretty much lets you make whatever shapes you want. So keep an eye out for 1.30, I’m hoping to have it out by the end of the week.

      Delete
  4. I want to buy the SUN in your demo video :)

    you can send me email at brianbraatz (at) g m a i l

    ReplyDelete
  5. Replies
    1. Hey Matt,

      I just tested the scripts in 3.5 and they work fine, they might even work in lower versions, the Demo Scenes however are not working, they can only run in 4.0 and up. I’m in the process of trying to back port to a lower version so that it’s available for more people =)

      Delete
  6. I just picked up the script. Very nice. Everything works as expected.

    I have a request for advice though. Could you maybe point me in the right direction for creating a planet walker with this script? I basically want to have a character walking around on the surface of the planet.

    I was using Faux Gravity before and that worked but your scripts seemed cleaner so I bought yours.

    Thanks!

    ReplyDelete
    Replies
    1. Sweet thanks man, glad you like it.

      How I would tackle something like this is by figuring out some way for your character to be aligned with the planet, maybe have some sort of empty GameObject point in the center of the planet for your character to aligned with.

      Then for moving your character around, I like simulated physics, so I would using the Rigidbody.AddForce method, you can kind of get an idea from the Marble demo scene in my package, just check out the control script on the marble.

      Try and keep everything physics related well managed so that you don’t get bogged down with the amount of processing. Also when using AddForce be sure to call it in FixedUpdate, and not Update.

      Hope this points you in the right direction.

      Delete
    2. Thanks for the speedy reply. I have decided to use the script I was using before and to augment it with your script. This gives things a real magnetism that I need but also allows players to walk around on the surface.

      In case anyone else comes across the same thing later down the road, here is a link to the scripts for the walking.
      http://forum.unity3d.com/threads/8873-Faux-Gravity-making-my-brain-spin-Help!

      As for these, I'm not sure if you use playmaker at all but I'm making some weapons with your script that are pretty interesting and when I get done, I can post the link to the actions. Might be useful to other buyers.

      Keep up the great work and I'll let you know what I make with this.

      Delete
    3. Awesome, yeah I'd love to see what you do with it.

      Delete
  7. how do i initialize the gravity script from scratch on a scene? I drag and dropped the script onto a sphere in a scene with 6 others, but nothing happened.

    ReplyDelete
    Replies
    1. When running your scene, do you see the lines drawn of the force around those 6 different objects? Also do you have a Rigidbody added to the objects you want the force to effect?

      Delete
  8. i just added the circular grav script to one object, no rigid bodies applied to anything in the scene. the only lines are the locator on the single object with it applied . does it have to be applied to every game object in the simulation
    9rigid body and circular grav script?

    ReplyDelete
    Replies
    1. Yes, it’s important to have a Rigidbody attached to the item you’re effecting. For example, if I wanted to effect a cube, simply add a cube to you scene by:

      1) Going to the top menu and select GameObject->Create Other->Cube
      2) Then select the Cube in the scene
      3) Then select the top menu and select Component->Physics->Rigidbody
      4) You should now see that there is a Rigidbody attached to the Cude

      More Rigidbody info here:
      http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html

      I would suggest you look over my tutorial on How to Use:
      http://www.youtube.com/watch?feature=player_embedded&v=SWoUG9UFCwI

      I would also recommend that you try messing with the Tutorial scene that’s included with the package first to get a better understanding on how the scripts work.

      Delete
  9. Great asset, purchased yesterday and having a blast, is there a way to maintain a constant orbit around a planet ? was thinking maybe with a min / max distance would do this. the planet example is great but the orbit decays eventually, i'd like to be able to have a load of satellites orbiting a planet at a constant velocity and be able to nudge the out into space by applying a force.

    cheers
    Neil

    ReplyDelete
    Replies
    1. Hey Neil,

      Thanks glad you like it, sorry =( I don’t think you would be able to get a constant orbit using this script, but if you wanted a consistent rotation around the object you could use the RotateAround script that’s included with the package, if that helps.

      Delete
    2. Hello. Just wondering if, with the last updates, a constant orbit could be achieved with this script?

      Delete
    3. Hey Chad,

      It still acts pretty much the same, you might be able to get the effect you want by adding a initial velocity to the object and shoot it towards a planet like how I have the planet demo http://goo.gl/YP9glT but that might act a little randomly, or you could just use an animation or a script with the RotateAround funcion. I did add a new category 'Constraint Properties' under the CircularGravity.cs with the options to 'Align to Force' that you might find helpful, I do plan on adding more options in the future under this, maybe even a constant orbit option, I'll keep you updated.

      Delete
  10. Hi Lane, I'm trying to add the script to objects at runtime. I add RigidBody then CircularGravity, but I get errors that an object reference is not set to an instance of an object. It seems to pop up around pulseProperties. Is there something else I need to do?

    ReplyDelete
    Replies
    1. Hey Adam,

      So you're trying to add the script to the gameobject while the project is running?

      Delete
    2. Ok I see what you mean, I’ve never really assigned the CircularGravity script to a gameobject while in runtime before. So a way to fix this is to check and see if the Serializable Properties are null, if they are then New them in the Awake function. I will go ahead and spend some time looking it over more to make sure this is the case and add a fix in the next patch, if its quicker send me a message at avenue.lane@gmail.com and I’ll send you the code to add to the Awake function.

      Delete
  11. Hi there,

    I'm wanna make a small Game what is a little bit like Mario Galaxy, but from the ego view.
    My character is a full rigidbody game object and of course there a many other rigidbodies in a scene as well.

    Now I'm wondering if your asset for Unity is the tool with that I can easily archieve that?
    Here is an example of how it could work: http://www.youtube.com/watch?v=Hnwbay_NTXY

    Cheers,

    Nico

    ReplyDelete
    Replies
    1. Hey Sup Nico,

      This script works well for pulling objects to a source like a planet, but keep in mind this doesn't include controls for walking around on a planet, you'll have to find a other solution for solving that problem. Its a good start though, hope that helps.

      Delete
  12. Hey Lane awesome plugin, it works great.

    I saw another user post a comment in your reviews:

    "I did make a modification to the script to make the force square-proportional with distance to better meet my requirements. Not difficult to implement, but I'd suggest to the developer that this could be added as an additional integrated feature."

    Were you able to get this to work? I would help me a ton with my current project. Please e-mail me if you have the time. simplyjames@hotmail.com

    ReplyDelete
    Replies
    1. Hey James,

      Yep added it in the 1.50 version, I also have a a few demos and a tutorial on how to get it to work. Links below, be sure to backup your code if you are using an older version.

      Demo1: http://lanemax.blogspot.com/2013/05/this-shows-vacuum-demo-using-triggers.html#comment-form
      Demo2: http://lanemax.blogspot.com/2013/05/this-demo-shows-power-of-using-triggers.html#comment-form

      Tutorial: http://lanemax.blogspot.com/2013/05/this-tutorial-walks-you-through-how-to.html#comment-form

      Delete
  13. Error
    Hi Lane,
    Weird problem. Plays fine in Unity game mode. When I do a build and run no gravity powers. Did with my own scene and with one of yours same problem...help.

    ReplyDelete
    Replies
    1. Hey 24,

      I just double checked the version from the asset store and it seems to work fine. Can you be a little more specific on what errors your getting? Also when setting up your scene are you sure you have rigidbody on the objects you want to effect? Also check this tutorial demo out on how to use it http://www.youtube.com/watch?v=SWoUG9UFCwI let me know if that helps any.

      Delete
    2. Ok, after seeing your post on the asset store, It seems your having a problem with the webplayer correct? I looked into it a little further and found that there was a problem with webplayer builds. I will go a head and fix this in the next patch. Until then, if you like, I can send you a small fix if you email me at avenue.lane@gmail.com

      Delete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Zplintz ZeeSeptember 26, 2013 at 12:53 PM
    Lane,

    Hi. Great package and really good value for money.

    I have a need to have uniform gravity towards surfaces mounted on the inside and outside of a polyhedron. As the gravity effect will be slightly less on the edges of a flat face (where the face normal points at the gravity source) than at the centre of that face. It is ok for me to add additional functionality by copying and modifying your scripts?

    ReplyDelete
    Replies
    1. Sure! Sense you've purchased it feel free to modify it all you want =)

      Delete
  16. Hi there. I bought your script intending to use it for a game where the player can walk around on a small planet's surface, like Mario Galaxy. I'm having trouble keeping the character controller always vertical, against the gravity in your script. Do you have any suggestions on how to accomplish this? Is there an easy way to derive the direction of gravitational force being applied? Thanks!

    ReplyDelete
    Replies
    1. Hey Josh,

      So how I would go about solving this problem is making it so that you Character is always aligned to the Circular Gravity gameobject point. One way you might be able to set this up is by using the transform.LookAt(…) function on your character controller, you might have to mess with it a bit, but hope that points you in the right direction.

      Delete
  17. Hey Lane,
    I just bought your script. I want to know if I can use it with the Shuriken ParticleSystem.
    I followed your tutorials, but I can not add a circular force at the center of my particles.
    You can send me email at shiyue@soixantecircuits.fr
    Thank you very much!

    ReplyDelete
    Replies
    1. Hey Shiyue,

      Currently the way the scripts have been programmed it only works on objects that have a rigidbody & collider component, so sadly the script doesn't work for particles, unless you can figure a way to add a rigidbody and collider to each particle. You could also make an gameobject that has a rigidbody and collider with a ParticleSystem, but that would only work on all the particles within the gameobject, Let me know if this helps.

      Delete
  18. Hey Lane,

    Great package, been enjoying using it a lot!

    I came across one problem that I thought I would share - to do with using the trigger areas to shape the area of effect.

    My problem was that I was using a very long cylinder shape as the trigger area. Because I wanted the origin of the force to be very far above the objects it was affecting, I had to increase the radius a lot in order for it to reach.
    Doing that meant there was a huge number of objects being affected, and because the trigger area works by only *removing* objects from the collection rather than excluding them from being added, it was causing a big performance hit.

    My solution was to stop using the trigger area, and instead override the method to use Physics.CapsuleCastAll to populate the collection, which worked great for my situation, though I'm not sure it'd be applicable for a lot of other circumstances.

    Please let me know if I'm doing something wrong here, and if not, hopefully that's useful to you in some way.

    You can see it in action here http://vimeo.com/79157588
    ... and the code here https://github.com/Adrianis/Env/blob/master/SwarmParts/Hoover/CircularGravityBeam.cs

    Thanks

    ReplyDelete
    Replies
    1. Hey Sam really sick simulation! I can see how with this many gameobjects how performance could be hit. Really good solution you came up with, I'll have to mess around and see if I can make some performance changes or even maybe adding features around your solution with the CapsuleCastAll function. Thanks a lot for the feedback! Really awesome to seeing what people are come up with using the package, if I end up making any updates it’ll be in the next version, I’ll keep you updated. Thanks again =)

      Delete
    2. Hey Sam so I'm in the middle of adding a pretty sweet feature, Im adding the ability to pick a shape of the force, sphere which is default, raycast, and in your case the capsule. I'm still doing some testing around the changes, but hope it will be finished soon.

      Delete
    3. Fantastic, sounds like a great addition! Thanks for the praise as well, if all goes well I should have the game finished soon. I'm just glad I could contribute something back :) Once you're done with the update I'll try it out and let you know how it goes.

      Delete
    4. So just sent off the new changes to Unity, hoping to get it approved within the next few days. Until then feel free to check out the new demos here http://www.lanemax.site50.net/AssetStore/CGF_v2.0/ let me know what you think =P

      Delete
    5. They're great I love them! You really went all-out remaking them all with the new system, the new ones are awesome as well, particularly Invention - there's a puzzle game in the making there :)
      Great work, looking forward to checking out the code!

      Delete
    6. Alright Sam update is live ^.^ be sure to checkout the v2.00 released notes at the top. Also be sure to backup all code before updating

      Delete
  19. Any way to make this work with 2d collider's?

    ReplyDelete
    Replies
    1. Sadly no, it only work with the regular colliders. I am planing in the future on making a 2D version, but I'm currently waiting for the Unity Devs to make a few more updates to the 2D side of things before i start implementing it. I'll keep you updated when its in the works ;)

      Delete
  20. Hey Lane,

    This is a very cool addon. My only problem is I can't get a character to walk around the sphere. He just kinda shakes and falls over. It's kinda funny but not what I'm after. Haha. I'm very new to programming so I was wondering if you had any simple ideas I could try? Thanks in advance!

    ReplyDelete
    Replies
    1. Hey Sup TheNakedVetTech =P

      So I'm guessing you're trying to make like a Mario Galaxy kind of effect right? Keep in mind my packaged doesn't include controls for walking around on a planet, but this might help. I get this question a lot so here is kind of a repeated answer from the top of the form.

      "How I would tackle something like this is by figuring out some way for your character to be aligned with the planet, maybe have some sort of empty GameObject point in the center of the planet for your character to aligned with. Then for moving your character around, I like simulated physics, so I would using the Rigidbody.AddForce method, you can kind of get an idea from the Marble demo scene in my package, just check out the control script on the marble. Try and keep everything physics related well managed so that you don’t get bogged down with the amount of processing. Also when using AddForce be sure to call it in FixedUpdate, and not Update."

      Also maybe another solution or idea:

      "So how I would go about solving this problem is making it so that you Character is always aligned to the Circular Gravity gameobject point. One way you might be able to set this up is by using the transform.LookAt(…) function on your character controller, you might have to mess with it a bit"

      Hope this points you in the right direction. Let me know if this helps or have any other questions =)

      Delete
  21. I'm not sure if this has been addressed but I want to do a game that takes place on the inside of the sphere. Do I want to just remove gravity from all objects and then include a gravity source with a positive force to the center and thus allowing me to walk around on the inside of the sphere?

    ReplyDelete
    Replies
    1. Seems like that would work, wow that would be really cool. Only thing you have to figure out is the walking controls.

      Delete
  22. Could I use your physics system to make fast collision simulator that resembles an abacus?

    ReplyDelete
    Replies
    1. Yes, exactly like an abacus. Whether you move a sphere slowly or quickly neither should go through the other's geometry.

      That's the issue I have with Unity's built-in physics.

      Delete
    2. Hmm don't really know if this is the asset is really going to fix your problem, sense I used the Unity built-in physics. It would be pretty useful if you had the physics working, because you could easily pull the spheres whichever way you wanted. Are you moving the objects pretty fast?

      Delete
    3. The idea of the game is to collide objects at any speed and expect a real world reaction, and that has been the problem all along.

      Any help would be appreciated

      Delete
  23. Hi,

    I just bought your Circular Gravit Force and I don't know if I missed something but to me when I try to implement the CircularGravity on a sphere and let another object fall into it it look like your script really isn't a circular gravity script but rather a six axis gravity script. My conclusion comes from testing with a cube falling towards a sphere and if I put the cube exactly on one of the six axis the cube falls towards the sphere and comes to a rocking halt as expected. But if I move the cube to a random angle from any of the axis, still being perpendicular to the sphere and let it fall it rotates and hits the sphere surface and start moving towards the nearest axis circulating around the axis and finally settles at the axis. I would have expected the cube to rather have reacted exactly the same regardless of position around the sphere if the gravity where indeed circular (or rather spherical). Am I'm missing something?

    Sincerely,

    Johan Israelsson

    ReplyDelete
    Replies
    1. Hey Johan,

      I’m not entirely clear on what’s happening in your scene, but one thing you might try doing is creating a ‘Physics Material’ with some friction, then try assigning it to your sphere and cubes, and see what happens. Another thing you might try doing is messing with different settings with the force power, and the Size properties settings. Let me know if this helps any.

      -LaneMax

      Delete
  24. I have a 3D scene, but many of the objects in my game are restricted to 2D X and Y movement only. Is it possible to restrict movement in the z direction with your script?

    ReplyDelete
    Replies
    1. Hey rooter,

      Sadly no, but that would be pretty cool and easy to add, I'll look into adding it. But one way you can do this is by selecting all your objects that have a Rigidbody component and click the checkbox under Rigidbody->Constraints->Freeze Position->z that should lock the z direction.

      Delete
    2. Great thanks. That is exactly what I am doing, I just wasn't sure if your script would override the rigidbody setting. Thanks!

      Delete
  25. Hello Lane, I work very good with your Circular Package.
    I need know in each object the atraction received. How can I get this value from each and all "circulargravity" ?

    I am very novell in Unity3d, and I have now working with th 4.5 free. Waiting to buy the 5.0 :)

    Please, can You help me ? With the vector of each gravity, I get a resource to apply to each object.

    THANKS.

    ReplyDelete
    Replies
    1. Hey Julian,

      So under the circulargravity class you should be able to get all objects effected in a list under the this.specialEffect.effectedObjects.effectedObjectList[] I don't know exactly how you would get the force applied, but you might be able to calculated it based on the rigidbodys velocity.

      Hope this helps

      Delete
    2. Also make sure to have a value supplied under the Special Effect->Time Effected field in the circulargravity gameobject properties, this will be how long the effected gameobject is within the list of objects, if its zero the list will not populate.

      Delete
  26. Hi Lane, please.
    In Javascript I need change the "forcePower" from a parent gameObject that has the 'CircularGravity' script. This is in C# and I need change via script writed in Javascript.

    Thanks for reply.

    Disculpme my bad english.

    ReplyDelete
    Replies
    1. Hey Julian,

      Sorry I'm so late getting back with you, I've never really used javascript. But in C# it would be something like

      parentGameObject.GetComponent().forcePower = 100f;

      Hope this helps

      Delete
  27. ALL SUPPORT MOVED TO THE UNITY FORMS

    http://forum.unity3d.com/threads/circular-gravity-force.217100/

    ReplyDelete