I developed a game where the user adjusts the angle and power to launch the ball with to try to score in the goal. I designed a Plane with a large amount of vertices for the mesh and imported it to unity. The ball hits the net well although the net not always stretches. for example if i set the angle to 17 degrees and power 100, for some reason, the cloth doesnt work. But regarding an issue im having with it is that I want to not simulate at the beginning, and should only simulate when the ball hits the cloth. The other thing: Is there anyway to make the cloth stretch even more and engulfs the ball in a way ? Thanks
Related
im creating a rubiks cube solver and simulator for my a level project and i have come across the problem of the top face of the cube not rotating properly. After a few tests of it i have come to the conclusion that the top face is rotating around the axis properly but in order for it to stay in line witht eh rest of the cube i also need to update the other axis. This is my code to rotate the face
for (int i = 0; i < 90 * n; i++)
{
cube[0].rotateY(degree); // degree is defined as Math.PI / 180 as its in radians
cube[3].rotateY(degree);
cube[6].rotateY(degree);
cube[9].rotateY(degree);
cube[12].rotateY(degree);
cube[14].rotateY(degree);
cube[17].rotateY(degree);
cube[20].rotateY(degree);
cube[23].rotateY(degree);
Invalidate();
}
I have tried also rotating the left and right side and they both work correctly while using the same function but for the other axis. i have definitions for the entire cubes rotation stored in rotation with x y and z properties. Initially i thought this wouldnt be a very hard fix so as well as rotating each cube on the y axis i rotated them along the x axis but for -rotation.x * 2 in order to counteract the problem however this didnt work and just transformed it into very weird positions. Im sure its just a simple maths expresion that i need to rotate it by but i cant work it out.
As i found it hard to explain my problem ive created this video to show it visually. You can see that the left and right rotations work although they are not yet animated and the top face rotates round and always snaps back into the original position but not the other 4 correctly. I am also aware that the colours dont come round the cube like they should but this is something i will work on once all the rotations work
Video of current coded soloution
the functions for the rotations simply update the rotation variable and redraws the cube and all the different cube's in the array are just there as i have created 26 smaller cubes to create 1 bigger cube so that rotations can work without just changing the colour.
If anyone has a nice maths equation to rotate this correctly that would be great but if not and you have another way of rotating the cubes in the cube then that would also be great.
Also just a side quest if anyone knows why my code doesnt rotate the side by 1 degree and then redraw it again inside the Invalidate command then id love to hear why.
Many thanks in advance.
When I was testing my game written in Unity 3D, I see that the camera traspass the wall on the left superior part but in the right superior part don't do it.
Can anybody help me please?
A picture - the error is up at the left:
The wall is closer than the shortest distance at which the camera can render. The distance is called near clipping plane. You can change it from the inspector after you select the camera. Set it to a very small number like 0.01 to render objects at a very close distance and avoid this issue.
Keep in mind that as your far/near ratio increases, your depth buffer precision will decrease which can cause some artifacts. So only reduce the near plane/increase the far plan as much as you really need.
This is something i've struggled with all week. I'm working on a 2D project, and what I want is for my enemies to move from the right to the left hand side of the screen (landscape). I'm moving them like this:
transform.Translate (new Vector3(1,0,0) * speed * Time.deltaTime);
At the same time, I want them to constantly rotate on a pivot in the middle of the sprite. As an example, imagine they are in space and are sort of floating uncontrollably, they would spin. I've asked this question a couple of times with no response so I guess my explanation isn't really very good. This is what I've tried:
Animating the objects. This didn't work because changing the Z rotation caused the sprites to spin in a tornado but not from one side of the screen to the other
This: transform.Rotate (0,0,50*Time.deltaTime); I messed around with the X,Y and Z properties but they pretty much all made a tornado type effect or rotated in 3d so disappeared when at 180 degrees.
I also imported a spritesheet where they are at different points in the "spin" so say at 10,20,30...360 degrees etc. but this wans't smooth at all
I hope this makes sense. I've spend quite a few hours on it now!! I can't get my head around it as I've moved from Xcode where this sort of stuff is 1 line of code. A point in the right direction would be amazing.
Note: if my question makes no sense please ask!
have you tried transform.rotation = Quaternion.lerp() ? I used this myself to rotate an object using an input though you could use it to do a random rotation on the z plane easily enough
This is the setup I have. I am trying to make a game in unity which appears 2d but is actually 3d. I have a simple sphere and a floor, which is made up of cubes placed next to each other(the colliders overlap a little) with the same Y value and Z value. My 2d plane is in X-Y plane(Z being the depth).
Now in the script attached to the sphere, in the Update function, I have used rigidbody.addForce() in the +ve X axis function to move the sphere forward. I have attached rigidbody to the sphere and enabled gravity. The collider of the sphere is the default one.
Now the problem is:
When I run this scene. The sphere moves forward but at the intersection of the colliders, it jumps a bit(very less but still noticable) upward and loses its momentum. It happens at every intersection.
BUT this does NOT happen if I place the sphere on a floor made up of a SINGLE cube(a very long one).
Is this problem arising because of overlapping colliders? How do I solve this issue?
Thanks in advance
I don't think this is fixable. Unity physics is approximate, and even when physics material are set up to 1.0 bounciness, momentum doesn't stay constant — I learned it the hard way when I tried to develop a game depending on constant momentum, and had to write my own little physics simulation for that.
I am playing around with Unity3D and adding physics to the objects in my scene. I currently have a sphere (planet) in the center of the screen, and I have another sphere (moon) positioned outside of it that is not moving. When I run the game I want the moon to orbit the planet by applying a force to it. I have been able to get the force added by calling rigidbody.AddForce() and that will move it in the specified direction but it won't orbit. I'm not sure how to add force to it so that it will continuously orbit the sphere at a constant velocity.
I've tried some examples using a ConfigurableJoint and it orbits, but it starts out bouncing a little and then starts the orbit. My goal is to have a bunch of orbiting moons orbiting at their own speed that are able to bounce off eachother but not lose their velocity.
Any ideas?
Generally speaking you will fail, eventually, because rounding errors in your integration method will slowly throw you out of orbit. You can get very close in the ways suggested, but you could consider doing something more like the Kerbal Space Program, which seems to precalculate the orbit as an ellipse and then follow that ellipse until it has a reason to believe it should stop, rather than strictly "simulating" the orbit ...
If a collision occurs, allow normal physics to resolve the collision, and then recalculate your new orbit based on the result and start following that.
For the moon to orbit you would need to give the moon an initial velocity. Then have it accelerate towards the planet, that is a constant force.
gameObject.rigidbody.AddForce(1, 0, 0);
gameObject.constantForce.relativeForce = Vector3(0, 1, 0);