• Unity3D - Discussion
    5,004 replies, posted
And should I separate the X and Y sensitivities?
I think I broke something: [video=youtube;efGNo84x0LE]http://www.youtube.com/watch?v=efGNo84x0LE[/video] What did I do wrong? [code] public GameObject[] gravityBodies; public float[] bodyMasses; void FixedUpdate() { Vector3 gravityVector = new Vector3(0, 0, 0); float gravityForce = 0; float distance = 0; foreach ( GameObject body in gravityBodies ) { // Get array index of current body int currentIndex = System.Array.IndexOf(gravityBodies, body); // Calcuate the direction of gravity gravityVector += rigidbody.position - body.transform.position; // Calculate distance to planet's center of gravity distance = gravityVector.magnitude; // Calculate gravitational force gravityForce += gravityConstant * ( ( rigidbody.mass * bodyMasses[currentIndex] ) / ( distance * distance ) ); Debug.Log("gravityForce: " + gravityForce); } // Normalize the gravity vector gravityVector = gravityVector.normalized; // Apply gravitational force rigidbody.AddForce(gravityVector * -gravityForce); } } [/code]
[QUOTE=Pelf;40589097]I think I broke something: What did I do wrong? [/QUOTE] -snip wrong-
Your gravity direction is wrong, gravityVector is completely off. The way it is now the directions are weighted by distance instead of inverse distance squared. Also, previous calculations of distance affect forces from subsequent objects. You probably have to normalize the force as vectors inside the loop, but you can reuse part of the gravity formula. Is there no AddAcceleration or AddVelocity? [editline]10th May 2013[/editline] [QUOTE=NinjaWilko;40591409]That code works fine here. Probably a different part that's causing it to go wrong. [img]http://puu.sh/2QqWl.gif[/img][/QUOTE] It only breaks with more than one gravity source.
[QUOTE=Tamschi;40591412]Your gravity direction is wrong, gravityVector is completely off. The way it is now the directions are weighted by distance instead of inverse distance squared. Also, previous calculations of distance affect forces from subsequent objects. You probably have to normalize the force as vectors inside the loop, but you can reuse part of the gravity formula. Is there no AddAcceleration or AddVelocity? [editline]10th May 2013[/editline] It only breaks with more than one gravity source.[/QUOTE] Ah, I only tried it with one since I didn't see the second in the video. My mistake
[QUOTE=Pelf;40587185]And should I separate the X and Y sensitivities?[/QUOTE] That also isn't really nessasary. In fact I find it an inconvenience because that is 2 sliders you have to adjust instead of just one. Certain people like to be specific with the sensitivity's, I would probably just leave it at the one slider for both.
N-body gravity now working! [video=youtube;8k0qnyfJIKA]http://www.youtube.com/watch?v=8k0qnyfJIKA[/video] its beautiful
I need to figure out how to do a (horribly broken) version of that for supra mayro goes galactical
[QUOTE=Eric95;40598495]I need to figure out how to do a (horribly broken) version of that for supra mayro goes galactical[/QUOTE] Here's my code (the gravity bits anyway) [code]public GameObject[] gravityBodies; public float[] bodyMasses; void FixedUpdate() { float gravityForce; foreach ( GameObject body in gravityBodies ) { // Get array index of current body int currentIndex = System.Array.IndexOf(gravityBodies, body); // Calcuate the direction of gravity Vector3 gravityVector = rigidbody.position - body.transform.position; // Calculate distance to planet's center of gravity float distance = gravityVector.magnitude; // Normalize the gravity vector gravityVector = gravityVector / distance; // Calculate gravitational force gravityForce = ( gravityConstant * rigidbody.mass * bodyMasses[currentIndex] ) / ( distance * distance ); // Apply gravitational force rigidbody.AddForce(gravityVector * -gravityForce); } } [/code]
[QUOTE=Pelf;40598831]Here's my code (the gravity bits anyway) [code]public GameObject[] gravityBodies; public float[] bodyMasses; void FixedUpdate() { float gravityForce; foreach ( GameObject body in gravityBodies ) { // Get array index of current body int currentIndex = System.Array.IndexOf(gravityBodies, body); // Calcuate the direction of gravity Vector3 gravityVector = rigidbody.position - body.transform.position; // Calculate distance to planet's center of gravity float distance = gravityVector.magnitude; // Normalize the gravity vector gravityVector = gravityVector / distance; // Calculate gravitational force gravityForce = ( gravityConstant * rigidbody.mass * bodyMasses[currentIndex] ) / ( distance * distance ); // Apply gravitational force rigidbody.AddForce(gravityVector * -gravityForce); } } [/code][/QUOTE] That's alot simpler than I expected... Is there some sort of formula you used for this or deeper explanation? I would love to experiment with this one day.
I just used [url=http://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation]Newtons law of universal gravitation[/url] to calculate the force that each gravitational body exerts on the lander. I used my own gravitational constant though.
Made a little unity player plugin for wordpress. Mainly for our internal office blog.. but I'll probably use it on my real blog at some point. I tried to make it really simple to do stuff.. because all the other solutions I found entailed logging in via ftp and blah blah bullshit. So here's how this one works. Go to add media [img]http://i.imgur.com/R9OgrI8.jpg[/img] Upload any unity3d file, insert into post [img]http://i.imgur.com/pWRm2mY.jpg[/img] It renamed the file when you upload it, with a .zip extension. This means you don't need to edit your httpd.conf to let you download unity3d files! It adds this special code to the post. [img]http://i.imgur.com/0ezqXHz.jpg[/img] You can full your post in.. [img]http://i.imgur.com/4a5fImC.jpg[/img] Then when you post it.. press play.. and it just works! [img]http://i.imgur.com/9f5X8jv.jpg[/img] You can press the full screen tv icon to go full screen too (not proper full screen - just full browser)
Spent the day adding game functionality to my n-body gravity setup. Did some graphical stuff so it looks much better now. I small problem though with my particles. When I crash into something, a few explosion particles emit along a line between the starting position and crash position of the lander. You can see it best at 720p: [video=youtube;8szCHH4B5Cg]http://www.youtube.com/watch?v=8szCHH4B5Cg[/video] Why is it doing this? Does anyone know how to fix that?
I love how easy it is to make stuff like this in Unity. [IMG]http://i.minus.com/iLMW95Ccjxiye.gif[/IMG]
Spiderman?
I guess so, it wasn't my intention.
Might as well post this, I made it a decent while ago. Someday I will continue it. [video=youtube;--UUv176vbo]http://www.youtube.com/watch?v=--UUv176vbo[/video]
I added unity3d tags btw [noparse][unity]http://url/to/my.unity3d[/unity][/noparse] [unity]http://garry.tv/wp-content/uploads/2013/05/out.unity3d.zip[/unity]
[QUOTE=garry;40628051]I added unity3d tags btw [noparse][unity]http://url/to/my.unity3d[/unity][/noparse] [unity]http://garry.tv/wp-content/uploads/2013/05/out.unity3d.zip[/unity][/QUOTE] Awesome. I like how you deleted my post about me suggesting you do this. Or maybe my internet was down when I attempted to post that. Nice work though :)
[QUOTE=Duskling;40631543]Awesome. I like how you deleted my post about me suggesting you do this. Or maybe my internet was down when I attempted to post that. Nice work though :)[/QUOTE] Excellent :D This will be very useful. :) until people put sound in their games and dont have a way to turn it off :P
testing the unity tags [unity]https://dl.dropboxusercontent.com/u/13781308/Unity/Center%20of%20Gravity/Center%20of%20Gravity.unity3d[/unity]
Might as well try? I have never compiled for the web before... [unity]https://dl.dropboxusercontent.com/u/7737298/games/floor/WebPlayer/WebPlayer.unity3d[/unity] Q and E also do things as well, not useful or super amazing things, but things. Perhaps we can have it a bit bigger?
Click the TV on the bottom right to make it bigger
[QUOTE=garry;40638247]Click the TV on the bottom right to make it bigger[/QUOTE] It works on Firefox now, but I can't exit from fullscreen. Edit: Nevermind, unusual button placement. Would be nice if it worked with the Esc key though.
[QUOTE=TM Gmod;40631899] until people put sound in their games and dont have a way to turn it off :P[/QUOTE] At least there is a play button so you are not automatically ear raped out of nowhere :L
Does this mean we all have to suck Garry's cock?
Why is unity doing this to my textures? -snip- What it's supposed to look like: -snip- [editline]edit[/editline] I'm stupid. I made it unlit>texture when it should have been unlit>transparent
Looks like you don't have any alpha on that texture.
Refined the paper's movement and animations. [video=youtube;l2siwBMJ3CI]http://www.youtube.com/watch?v=l2siwBMJ3CI[/video]
Working on some lighting and stuff. Does anybody know the best way to make the "bulbs" of those light posts emit light? For some reason using the self elum shader makes the shadows have artifacts. [IMG]http://i.imgur.com/i0kdA8w.png[/IMG] EDIT: Eh, until I get this problem fixed, changing the model and putting a point light a bit above seems to look decent enough. [IMG]http://i.imgur.com/SL25b81.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.