1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

Circular Gravity Force

Discussion in 'Assets and Asset Store' started by LaneMax, Dec 13, 2013.

  1. ataloss

    ataloss

    Joined:
    Jan 2, 2014
    Posts:
    52

    All you have to do is add the player Controller script from faux gravity to your character (see attachment). Then your character will be able to move on the planet while CFG keeps them planted on the surface..

    Hope this helps.

    upload_2016-9-17_9-13-39.png
     

    Attached Files:

  2. healym

    healym

    Joined:
    May 17, 2016
    Posts:
    19
    Is it possible to use this Mecanim? I'd like to create animation clips with this. Is that possible?
     
  3. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Yep, works great to! You can animate most of the main values like size, force power and etc, even turn it on and off
     
  4. healym

    healym

    Joined:
    May 17, 2016
    Posts:
    19
    Wow, that would be great! Sorry to reply so late, didn't know you'd respond so quickly! Do you have any tutorials that show how to use CGF with Mecanim? I think I'm ready to buy!
     
  5. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    I don't, but I've been meaning to redo a lot of the video tutorials. I could add that one to the list ;)
     
  6. The_Main_Character

    The_Main_Character

    Joined:
    May 19, 2014
    Posts:
    2
    Howdy,
    Would I be able to use this for a cubic world?
    For example in the truck demo is possible for it to have that same behavior but with a cube mesh and collider?
     
  7. SocialFreak

    SocialFreak

    Joined:
    Dec 12, 2015
    Posts:
    12
    I have been going through the tutorials and wondered if there is a way to create a tornado/hurricane type effect. Since the only shapes are Capsule, Sphere, Box and Raycast, I'm not sure how to approach this.
     
  8. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    3,611
    Maybe you could use something like this free asset and add onto it some gravity spheres? If the gravity spheres are revolving around and climbing an axis, it might create an effect like what you want.
     
  9. xagarth

    xagarth

    Joined:
    Sep 7, 2016
    Posts:
    6
    Hi,

    Great work so far!

    So what's the status for projectiles and particles for sphere worlds/planets.
    Will they bend accordingly?

    Or it's just magnet for rigidbodies.

    If I fire up projectile, a bullet, with rigidbody attached, will it go around the planet keeping distance to the ground and fall eventually?
     
  10. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hey The_Main_Character,

    Your pretty much limited to sphere shape. You could try using the sphere shape and see what happens, my guess it'll look a little weird.
     
  11. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    If it were me I would use different combinations of CGF shapes, and force types. Check out the vortex demo scene, that might give you some ideas.

    Cheers!
     
  12. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hey xagarth,

    Sense I'm relying on Unity's physics system it should. If you want a object to be effected you have to have a collider and rigidbody on the object in order for it to work. But for particles sadly they are not effected sense they dont have a collider and rigidbody, hope this helps.

    Cheers!
     
  13. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    316
    @LaneMax could you add a timer option to shut off CGF in particular for the explosion.. the field remains constant but should only be 1 second or so.. It would be nice to be able to customize how long the field lasts.
     
  14. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    316
    I would use a vertical 2 hollowed cylinders each shaped in a cone shape to form an hour glass with a mesh collider. Make it the size of your tornado and disable render.. then have it CGF attached below it with an upward force -maybe explosion and or pulse. I'd leave just enough room for the cylinder above ground to let objects in but maybe CGF underground. You could add more CGF Objects.. one could be angled 45 degree inside the hour glass on an angle. The idea would be that one CGF forces objects up ward with Gravitational attraction while the other CGF object above it pushes it sideways upwards on a 45 Degree angle to give the objects a spin in the hour glass. I haven't seen the Vortex demo scene so I'm not sure what might work best for the effect you're going for. The top part of the hour glass itself could have CGF added to it with force so the objects pulled up inside don't look like they are bouncing off a surface.

    One last way without the hour glass could be one CGF with gravitational attraction then several more above it spaced apart on a 75 degree angle all directing to the other CGF nodes above each other with the nodes set to gradually getting weaker as they go up.

    If you use the hour glass method you could potentially animate the physical shape with some of the vertex animators on the asset store.
     
    Last edited: Jan 5, 2017
  15. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hey Ascensi,

    There are a few different options you can take. First would be to write a timer script that enables and disables the cgf.Enable on and off. Or what I would do is animate the CGF object using an animation + mecanim. Let me know if this helps.

    Cheers!
     
  16. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Good news! Currently I'm playing with Unity 5.6 beta and I'm able to do any shape! Once Unity 5.6 is released I will have this feature implemented and released along with it. Click the link for a preview https://twitter.com/Lane_Max/status/819441649583538176

    Cheers!
     
    hopeful likes this.
  17. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    316
    Looks great! reminds me of Super Mario World Galaxy!
     
  18. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hey epicproblem,

    I'm currently working in parallels with Unity 5.6 beta for a big update right now. So far I have this fixed, and I'll keep you in the loop once I commit the new CGF update. I'm guessing for a time frame it'll be around when Unity 5.6 is released. Thanks for letting me know.

    Cheers!
     
    Last edited: Jan 29, 2017
  19. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    465
    Heya there! This solution works for Unity ragdolls? Requires an special setup or works on top of Unity physics layer?

    Thank you!
     
  20. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Its pretty easy, the only setup is setting it so it only effects the ragdoll rigidbodys, which is pretty easy under the filter properties. It's what I'm doing for my game =) here is a preview:

    https://twitter.com/Lane_Max/status/832500156989779969
     
    Novack likes this.
  21. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Just a FYI to everyone using Unity 5.6, you should be fine updating. You will get some untiy editor warnings, but nothing that breaks the content. I'm currently in the middle of making a pretty hefty updated, will keep the forum posted on the update.

    Cheers!
     
    Rujash, TonanBora and hopeful like this.
  22. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    1
    Hello, is it possible to combine this asset with a RayCast based 2D physics engine like Corgi Engine from More Mountains? I'm not sure if that is what was meant by 'NonAllac' support.

    I'm expecting this asset to allow vehicles to do inverting loops and, when near the ground, have an attraction to the ground that 'breaks' when too much force is exerted. Like in F-Zero: https://forum.unity3d.com/threads/how-in-the-world-were-the-physics-in-f-zero-x-done.204747/

    EDIT: Reading back in the thread, I just noticed someone else requested something similar. I will read up on it.

    EDIT2: I just watched your tutorial for your hover car. I think I can achieve a 2D F-Zero effect if I have two hovercraft scripts acting on the same object, right? So, one hovers it upward, the other hovers it downward. I predict there'd be an issue with a discrepancy between the two hovering scripts in where they want the car to 'rest' or some other unforeseen consequence of the two interacting. This could maybe be solved by just adding an extra force downwardly on the same hoverscript, when the object is above the value (height) that the player wants.
    The only possible issue I see is that, for my purposes, the hovercraft doesn't tilt. If I don't freeze that axis though, it should probably be fine. I want this for 2D, not 3D... So, I'm wondering if the hovercraft script can be used on a 2D object. In theory, it should.
    One problem with 2D and having it tiltable is that maybe the hover script behaves weird and on 2D slopes causes my character to spaz out.

    As for 3D, the same applies, but instead of turning the hovercar, one would 'strafe' it and rotate it along with the track which its attracted to. That would work, in theory, for the invert-enabled tracks, but problems would happen if you cannot turn the car on the flat-leveled parts of the track. Figuring that out might be fun.

    EDIT3: Diagram. There are 2 options for the downward facing hover script. M1 never limits downward force in the y+ direction, but ceases acting sometime above the car. M2 is a line segment, acting only in a specific area. At the beginning of the red and magenta lines, imagine that is a point away from terrain where the downward force ceases to act. This can be achieved by extending the downward hover script's detection line further into the ground than the upward hover script's, which is why the red line is relevant. Orange line is where upward hovering script stops influencing the car. Yellow is gravity.
    [​IMG]

    I think maybe the F-Zero car doesn't collide with the track, but the car is a child of a smaller box inside it. That smaller box is what drives the car and is affected by the track bottom. Then, the detecting for normalizing the box's angle with the ground is done with a y+ projecting raycast that is horizontally between the outer shell of the car and the box,so the box never hits an oncoming ramp and the car's bigger collision box doesn't hurt its maneuverability... except when it (car shell) collides with the side of the track or with another car. Could just be a very strong hovering script, though. Or some kind of spline. It's all theorizing how the original F-Zero was done.
     
    Last edited: Apr 7, 2017
  23. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hey Rujash,

    Thanks for the message, I'm not to familiar with the Corgi Engine, but I would guess that you would still be able to use CGF as long as you have a rigidbody2D and a collider2D on the gameobject. 'NonAllac' basically means, if you have it enabled, it will not use memory.

    Yeah as far as the hovercraft goes I'm currently in the middle of a update that will make this a lot easier. The way I was doing it back then had a lot of problems, including the axis locking which you are running into now, which really isn't the best way to solve that problem. I'm even going to have a 2D Hovercraft example in the next updated which will be coming out soon, I'll keep you posted.

    Cheers!
     
  24. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,247
    I need to set up gravity on a ringworld-type environment -- that is, creating the effect of centrifugal force against the spinning inner surface of a circular band (or like in a wheel space station).

    Could I do this with CGF? From the videos, looks like I'd just set up a sphere with Gravitational Attraction, with gravity set to a positive (repulsive) value from the center of the sphere....except that this would give objects a lateral push (sideways on the curved band) as well as an outward push. Is there a way to make the center of gravity linear rather than a point?

    thx
    Dave
     
    Last edited: Apr 28, 2017
  25. veven

    veven

    Joined:
    Sep 12, 2012
    Posts:
    5
    Hi, I just bought CGF last week. I'm really enjoying using it so far, but I hope you can help me with something.

    My scene has a PlanetCGF (Shape: Sphere, Force Type: Gravitational Attraction, Force Mode: Acceleration, Force Power: -1000). Then I have a PlayerCGF that is meant to make the player float when activated, the settings are (Shape: Raycast, Force Type: Force, Force Mode: Acceleration, Force Power: 10). It's pointing up through the player and works well.

    What I want to achieve is the player floating at a certain height in the air when a key is held down. So I have a CGF_Key Controls script that turns on the PlayerCGF Force, and a separate script that constrains the players rotation. So far so good.

    What I don't know, and could use your help with, is the correct setting for the PlayerCGF's Force Power to make it perfectly counteract the PlanetCGF's gravity. When I use Unity's standard gravity, setting it to 9.81 achieves what I want.

    I've narrowed it down to a value between 11 and 11.1... I think. But the behaviour is weird, and I'm not sure I'm approaching this problem from the right direction.

    Actually, is there a better setting for the values that would help me achieve the right effect? I may have to introduce some separate magic to get the right look, like a collider that stops it from moving up anymore, or a temporary script to clamp the position's maximum value. But I'd love to figure out how to achieve this effect natively with CGF, if possible.

    Perhaps there's a specific equation I could use to calculate this value for a given CGF? I looked for variables on the CGF object that might give me clues, but found nothing.

    Any help would be appreciated. Thanks. It's been a joy to use so far.
     
  26. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hey Dave,

    Yeah that might be a pretty tough problem to solve. In my next update I do have a solution for using shapes rather then just a sphere, there is some limitations though, you can only use convex colliders, and Unitys basic primitives. You might be able to if you split the ring in to parts and set it to convex. I'll keep the forum posted when the new version with this feature comes out which is in the next update.

    Cheers!
     
  27. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Hmm yeah you might have to write a script. Maybe you could use Physics.ClosestPoint for calculate the strength of the CGF? You would have to supplying the Physics.ClosestPoint with the player's vector, and the collider of the planet to get the closest point, and use that to find the distance between the planet and the player, then use that distance value to control you CGF. Don't really know if this will help, let me know.

    Cheers!
     
  28. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
  29. healym

    healym

    Joined:
    May 17, 2016
    Posts:
    19
    Hi,

    I'm interested in making a tilting table that changes its incline based on the position of a ball. I'd like to start out with a platform that's flat with the ball in the middle. The angle of the tilt would be determined when the player hits the ball with a paddle and the ball passes through a collider. By placing these colliders around the table on all four sides I thought that possibly I could make the ball and table continue to move automatically. Can this be done?

    Also, I'd like to use this with another asset that already utilizes Unity physics (such as the ball itself). Do you think your asset would conflict with this other asset?
     
  30. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    I guess I'm having a little bit of a hard time understanding the question and how you would use the physics content. Do you have maybe a screenshot?

    As for as compatibility goes, it really depends on what the other package is doing. My content only applying Unity's physics to objects that have colliders & rigidbodys, if the other content is taking control of that, then that would be a problem.
     
  31. yamlCase

    yamlCase

    Joined:
    Apr 13, 2017
    Posts:
    9
    Lane, I really like your assets. I made a short video while evaluating SSS and CFG. This is testing out the Gravitational Attraction force.

     
  32. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    Nice!
     
  33. yamlCase

    yamlCase

    Joined:
    Apr 13, 2017
    Posts:
    9
    Hi Lane, I'm attempting to access the ForcePower property using your script as a template from your March 2016 post, but something is wrong. I get NullReferenceException: Object reference not set to an instance of an object
    engine.Update () (at Assets/engine.cs:13)
    on the cgf.ForcePower = Nf; lines:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. using CircularGravityForce;
    6.  
    7. public class engine : MonoBehaviour {
    8.  
    9.     public CGF cgf;
    10.  
    11.     void Update () {
    12.         if (Input.GetKey(KeyCode.Space))
    13.             cgf.ForcePower = 2f;
    14.         else
    15.             cgf.ForcePower = 0f;
    16.     }
    17. }
    Did something change with the latest asset? BTW I'm on the CGF + SSS bundle if that makes a difference.
     
  34. yamlCase

    yamlCase

    Joined:
    Apr 13, 2017
    Posts:
    9
    Figured it out: drag which CGF I'm referring to into the script box. Thanks for being my sounding board :)
     
  35. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    157
    lol just looking into it, was just about to say the fix ;)