Tag Info

New answers tagged

0

Its much simpler than you think: Just use the "relative velocity" to calculate the impulses and use this to project it against the normal. relVel = vB - vA; The normal ist just (posB-posA) / Length(posB-posA) aka normalized. Impulse = -(1 + coefficient_of_restituition) * relVel dot Normal / (invMassA + invMassB) coefficient_of_restituition = 0 (100% ...


0

So the aabb is the axis aligned bounding box and so if it is giving you errors about it that means that unity couldn't calculate the aabb of an object because either it's too small or to big or has some kind of negative size or doesn't have a transform. Your other error is probably causing the invalid aabb error as the aabb does rely on the position of the ...


-1

You could raycast to judge whether the character is standing on a slope and modify their velocity accordingly.


-1

the raycast is a good idea,you may use ray judge whether it is a slope ,then you can controll the velocity by changing the player velocity.


1

Here is a C# script for a GravitySource component. It requires a Collider attached to the same game object with the "Is Trigger" checkbox set. This collider represents the zone of influence of the bodies gravity. Any Rigidbodys inside of that collider will be affected. The public property gravity needs to be set in the inspector. It represents the ...


3

Andon's answer didn't quite give me solution, but it definitely put me on the right track! Once I began thinking of the wheels being on their own plane (the normal of which being the vector sticking out from the centre - I'll refer to this as the wheel's "normal") I realized the side force is just the vector required to 'push' the car's velocity onto this ...


2

The answer is a YES, You may set the gravity vector to (0,-some number) for this purpose, your code which multiplies the g scalar with sin and cos of 45 degree will be true if the SpriteKit physics coordinate system could be changes to your isometric coordinate system, I mean the direction of the gravity vector is still the Y axis, look at your Z axis ( ...


6

That side force is the horizontal component of the road's normal with respect to the car's forward movement. Roads are banked like you are discussing to facilitate cornering at higher speeds without flying off the track from momentum pushing them to the outside corner. The banking pushes back in a direction the tires do not freely rotate and can hopefully ...


1

Assuming A at position 0,0 free fall equations (with starting velocity on x (Vx) , and g=gravity constant ) are: (1) x=Vx * t (2) y= (1/2)*g * t^2 substitute t in second eq. you get (3) y= (1/2) * g * (x/Vx)^2 where g and Vx are known. This is a parabola equation : Intersect (3) with each wall segment to get the eventualy collisions point ...


1

The rope in your example is probably just a simple physics-joint that limits the distance of the ball to the mouse-cursor. These joints are typically called "Rope joint" or "Spring joint". It seems like the ripples in the string are not based on an actual physics-simulation. Most likely this is a bezier-curve where the control points get further pushed away ...


1

From here, this can be used to calculate the volume of an arbitrary 3D mesh. public float SignedVolumeOfTriangle(Vector3 p1, Vector3 p2, Vector3 p3) { float v321 = p3.x * p2.y * p1.z; float v231 = p2.x * p3.y * p1.z; float v312 = p3.x * p1.y * p2.z; float v132 = p1.x * p3.y * p2.z; float v213 = p2.x * p1.y * p3.z; float v123 = ...


2

When the user presses the "orbit" button, store the vector between the ship and the planet. On every update, change the vector's angle leaving magnitude the same and then update the ships position by adding the planets position and the vector pointing at the ships new position. This will create the effect of the ship moving in a uniform circle around the ...


6

Basically, you'll need to create a physics engine. A rope is conceptually a bunch of "nodes" connected together with springs. Basically, every tick, each nodes will exert a force on the nodes above and below it proportional to their distance apart (or how far from their comfortable stretch length they are). If you want to attach a ball, just connect it ...


0

https://www.youtube.com/watch?v=bh9ArKrPY8w You have options. You can either use a bunch of primitive colliders (which will be most efficient but also the most time consuming and tedious option), or you can use a simplified mesh created specifically created to be used as a collider. The above video goes into more information about colliders and goes over ...


0

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy. Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as if (x2-x1)>=0 if (abs(x2-x1) < ...


0

In order to do this you need to simulate inertia. This is how I would recommend doing it: class Ship { public Vector2 Pos; //Current ship position public Vector2 Vel; //Store current velocity as a vector public float Rot; //What direction the ship is facing in radians public float Accel; //Maximum acceleration public float MaxSpeed; ...


0

Per a comment to the above question State Syncing seems to be the way to go. Saves me updating every frame.


0

You should proceed in the following way 1) Get the input mouse position convert it to world co-ordinates Vector3 direction = Camera.main.ScreenToWorldPoint (Input.mousePosition); 2) Now calculate the directional Vector3 form anchor of the hinge joint to the input mouse position. Vector3 diff = direction - Anchor.transform.position; 3) The last step ...


0

It does not seem like you have made the mistake (If your gameobject has a transform) Try restarting Unity, rebooting your computer, reinstalling Unity.


0

You could try and create 3d game objects like cubes and spheres, then as those have colliders place them somehow to fit approximately the walls, the floor and ceiling and then just remove the mesh renderer component from those objects to make them invisible.


0

one solution may be : import models in unity without mesh collider, then manipulate your unity scene adding empty/invisible objects containing the colliders (box colliders?) you need to delimitate walls and floors.


0

Just to add to some others' answers here, something that no-one has explicitly mentioned: If you do take the risk of running your game loop in a second thread and it becomes unresponsive, you risk the OS terminating your application. That's why it's recommended to use a separate thread. Hence (for example) the NDK's native_app_glue.c/.h spawns a separate ...


3

Each rigid body has an attribute indicating if it's affected by gravity or not. You can just mark that attribute as true, whenever player enters the spaceship, and later turn it false, when he exits. But that'll limit you with a big limitation. The gravity itself in unity is something global, meaning all entities are affected by same gravity force (if any). ...


0

Under the rigidbody tab in the hierarchy freeze rotation X and Z. This will keep them from falling over. Then you should be able to apply gravity on the Y axis without a problem.


4

I'm using Hooke's Law here as the definition of a spring. () Given the derivatives of position and velocity, are velocity and force respectively, we can construct a differential equation for the stretching of the spring. Which is just a damped harmonic oscillator, and since we already know that only the under-damped case need analysis, we can obtain a ...


1

i did something similar a while back, it's not that hard, one very easy and understandable way is : 1- rotate everything! means every line every object, so everything is simply flat! 2- calculate velocity, gravity, friction and ... anything you like ! just the way you always do in a flat and without rotation world 3- rotate everything back the way it was ! ...


2

I spent a good while looking how to implement Box2D in Android studio, so for anyone else in the same boat, or just looking to implement Box2D - here goes. For implementing Box2D into your java code/framework, Box2D is tuned to work with numbers between 0.1 and 10 (it works in meters), quoting from the Box2D manual: http://box2d.org/manual.pdf Box2D ...


0

Use transform.forward instead of Vector3.forward


0

I discovered that I needed to do the following: Set the moving cube with weight of 1 and then setLinearFactor to x,0,x and setLinearRotation to 0,0,0. This allowed me to use setLinearVelocity as expected and then increase the velocity of my sphere on top of the cube accordingly.


0

You should try using a Platform Effector.


0

I have not used Unity in about a year now so I don't remember a lot of the specifics, but I was just skimming this article earlier today and it looks helpful. (scroll down to moving platforms) Note that the content below was copied from the link above, and the wording slightly tweaked with Unity in mind. Moving Platforms Moving platforms can seem a ...


0

You could increase the friction when player enters the collider of the platform, you can increase friction like this: GetComponent '<'Collider2D'>' (). sharedMaterial.friction = VALUE FROM 0 TO 1 (FLOAT) without ''


1

I was playing around a little and rereading the manual again. It noted that the size of the actual box is 2x the given size. Half-widths. So I continued to play around inside my graphics system and continued to see where the box was colliding and not and ended up with: Negate the (untouched) size from the position. Double the size of the boxes. glm::vec2 ...


1

You need a tensor for a generic solution. but the "specialized" solution here is that you have a a spin only if you have friction in your contact. otherwise of course the contact forces will purely be directed to the center of the circle and never cause spin. if you have friction, your forces will start to deviate within the realms of the friction cone, ...



Top 50 recent answers are included