Planet Gravity

I am trying to figure out the best way to make a gravity like effect around a sphere to where you can walk around it with out falling off the sphere. Any ideas?

Take for an example Planetary Annihilation.
27887-

One way to do this would be to create a sphere which will act as the gravitational field.

Anything inside this sphere will have a force exerted on it every frame in the direction of the planet. You can detect what is inside the sphere using overlap events.

You can get the direction to apply force by taking the actor’s current location, and the planet’s current location, and using them as inputs for the “Find Look At Rotation” node (actor being start, planet being target). The Rotator output will have its forward axis in the direction of the planet, so you could use a “Get Forward Vector” node on it to get the normalized vector to use as a direction to apply force.

Alternatively, it may be possible to use the “Add Radial Impulse” node at the planet’s location with a negative value, which hypothetically would pull in objects in a radius rather than pushing them away.

I haven’t tested any of this, but this should give you some things to think about and experiment with.

This is actually interesting. Reminds me of a trippy game where at one time the player gets teleported to a sphere(which was sitting in the same room as him) much smaller then his normal size(and while he was shrunk to fit it he was able to walk on it too). I would also like to figure this one out. I think that it’s possible to use sphere collision/detection mixed with sharp blueprint (or c++) coding to make it to where actors will move and rotate depending on where they were as apposed to the very center point of the sphere. And while this makes sense to me i can’t seem to get a formula made to describe this. Not even in 2D. But if anyone has a formula for this; Such as actor rotation = (…) and the filler would be variables related to planet(the physical sphere) and actor positions… please let us know. Even better if anyone knows of any shortcuts to calculate this please let us know. One thing i can contribute to this is that in order for the collision to work properly you’ll need the following. The planet at coords 0,0,0. Two collision sphere’s at the exact same coords. one of these spheres must be near the exact same size as the planet. This will act as the flooring. And the other collision sphere needs to be bigger then the planet. And should be used to represent the starting point of the outermost atmosphere. This way you have an indicater of when things would get sucked into it. And the distance between these two collision spheres could be used to determine the intensity of the gravity.

Again if anyone has experience with physics engines could they shed some light on the exact formula we would need to use? Or even better does anyone know of any shortcuts for effecting rotation of an actor by the difference of it’s position in relation to a point in space?

Dang right that was fast.lol Well thanks that actually seems to fill in some blanks. Because if the actor knows where the planet’s coords are and can face them, then it’s possible to add an extra variable so that the rotations would be opposite of this. I gotta experiment with this.

Dang while close to what i said this is actually helpful. I didn’t think of using the node that helps the actor face another actor. One could use an extra variable to flip this so the actor is facing the opposite direction(or by however many degrees) to get the effect i was thinking of. I must test this out.

I’m sorry for making the same comment twice. As a warning backing out of a forum and coming back in using the arrows(assuming your using chrome) doesn’t refreash the page.

Thank you all for your responses. Sorry it took so long to respond. I am still trying to use the above information to calculate the right solution. Another Idea I am trying to do is rely on the distance of a curve formula to make this work to. This will also help with the AI too i am hoping. Will post any and all the results if I can make this work.

Update on the core concept. Please tell me if it makes sense or not. Using the location of the character and the location of the AI, knowing which one to attack first, i will use the http://en.wikipedia.org/wiki/Great-circle_distance concept to measure the distance between the two. Still trying to figure out how to make it move on the sphere and how to apply the navmesh to the surface of the sphere.

That sounds like a serious challenge, and something not well-supported in the engine as it stands. My response deals more with the theory behind an object with a gravitational pull. I don’t know if it’s possible to use NavMesh for something like this, but I think you’re on the right track with that wiki article.

I’m starting to think that it might be best to have an outer collision sphere (or whatever shape) around each object grabbed by the world and use blueprints to find out what objects are within that radius in order for you to use a custom AI to walk somewhat in there direction. though perhaps adding intense gravity and having the objects move towards the atmosphere slightly when moving toward the other object. and you might want to make sure your objects are very small as well as your collision detection system for the AI. as far as seeing if there’s something in the way like terrain the only thing i can think of is using ray tracing and custom path finding behavior. maybe make an invis object do a ray trace ahead of the object but facing a different direction to get more data on the environment? this sounds very inefficient to me but i’d think it would work. how many npc’s or AI based actors are you expecting to use? ray tracing can be very calculation heavy. especially if you expect the world to be dynamic. if you don’t expect the world to be dynamic then perhaps you can craft your own collision fields to represent the nav mesh and base your ai calculations on that?

oh yeah fun tip. apparently UE4 uses an octree spatial collision detection system so use as many collision bodies as you can for calculation heavy work. it’s supposed to eat up more ram but reduces cost to cpu. look up spatial collision in google for more info as it’s a pretty interesting subject. and no dought you need to keep this in mine for something this outside the box.

Hi, how you cover or put color green in the space ? or automatically remove sun direction and change color ? chan you tell me ? thanks

Video link on how to do this in blueprints: