New answers tagged

3

A rational approach might be to simplify your problem. This is a game, so most of the time there is no need for 100% accurate physics. Instead of tracking every single component that makes your ship, you can instead prepare several damaged ship models and swap then on the fly as it gets more and more damage. When you swap the models, you could spawn some ...


1

You need to do something like this. its simple public GameObject YourGameobject;//refrence of your gameobject void Update() { if (Input.GetKey(KeyCode.W))//on W input it will disable the gravit of your desire object { YourGameobject.GetComponent<Rigidbody>().useGravity = false; } } You can change ...


3

This is in no way a complete answer. What you could try is: for each finger touching the interface, you calculate the distance and direction of each particle from the touch point. With the distance, you compute a force (use x as input, and have y result in something based on a logarithm or square function: the closer to the well, the stronger the force). ...


1

An Alternative Approach As very astutely stated by Dan in the comments to your question, trigonometric functions are very expensive to calculate and for something as simple as a bouncy ball you can keep to simple and fast vector math. It appears that you're only doing AABB collision so this method will work perfectly for you. What to change Your Ball ...


4

Based on my comment, here is what I'd do: Upon detection of the circle and the corner (this will be, IMHO, the most complicated thing to do), take the angle of the line segment between the centre of the circle and the corner (in RED), calculate the perpendicular to that (the tangent, in BLUE), and have the vector in (PURPLE) be reflected to the vector out ...


0

The whole setup seems a bit strange. Is the speed always a fixed number, and what you're dealing with now is how to choose direction? Or is the speed dependent on the movement as well? If the latter case (speed dependent on mouse movement): You should either make this "physical", i.e let the delta mouse movement result in acceleration, or link delta ...


0

Are you calling FixedUpdate() or defining it? I think you should delete the opening brace after FixedUpdate(), and add a ; directly after FixedUpdate(). In other words, if your intent is to call the method, you should write FixedUpdate (); If your intent is to define a new method called FixedUpdate (), you should write void FixedUpdate(){ //code// ...


2

First , your polarToComponent(magnitude, angle) { return { x: magnitude * Math.cos(angle), y: magnitude * Math.sin(angle) }; Called for each ball at start time, introduce a numeric error. So you must calculate the total velocity before starting simulation and compare with that instead of 30. Second your function checkCollisions() ...


0

So I realized how to do it. You need to override a method called Scene::update() with something like ball->getPhysicsBody()->setVelocity(ball->getPhysicsBody()->getVelocity()*0.995f); And later paste this into your Scene::init(), so the update() method will be called every frame(?). this->scheduleUpdate();


2

Here's one of my go-to jump functions. It's similar to a Mario jump - fast at first, slowing down until reaching the top. Please excuse the syntax. I haven't used C++ in ages, and never SFML. const float GRAVITY = 9.0f; const float MAX_VELOCITY = -10.0f; const float MAX_AIR_TIME = 1.2f; float timeInAir = 0.0f; float jumpImpulseTime = 0.2f; float ...


1

That's correct. In a few cases, you will want to take into account the rigidbody.inertiaTensorRotation. It defines the rotation of the moment of inertia. However, in most cases, this is just going to be the identity quaternion.


2

inertiaTensor is a Vector3, inertiaTensorRotation is a Quaternion. And from the docs for inertiaTensor: The inertia tensor is rotated by the inertiaTensorRotation. Essentially, inertiaTensor is the moment of inertia (defined as a tensor) and the inertiaTensorRotation is how that tensor is rotated. If you'd like them to be calculated automatically, you ...


0

I think I may have solved my issue. I managed write my own code: public class Anti_Roll_Bars : MonoBehaviour { private float force; private Vector3 pos; public float roll_bar; public WheelCollider wheel; public Rigidbody car_rb; public Transform car_tf; // Use this for initialization void Start () { car_rb = GetComponent<Rigidbody> (); } // ...


-1

why not set triggers that say.. ok the block is close enough.. turn off the rigid body and lerp it over the opening then drop down my increments until its in a desired position?


0

HealthBar.GetComponent<RectTransform>().sizeDelta = new Vector2(InitialWidthHealthBar * Player.pInstance.Health / Player.pInstance.MaxHealth,HealthBar.GetComponent<RectTransform>().sizeDelta.y ); This is the code that produced the same error.Where the Player.pInstance.MaxHealth is 0. It means 100 / 0 , which cause mathematical ...


0

You can try some some physic's projectile motion: From the horizontal displacement the maximum distance of projectile: d = v0 * t * cos(theta) where d is ab distance , v0 = start velocity, t= time , theta= trow angle (usualy Pi/4 for max trow distance) so v0 = d /( t * cos(theta) ) then you can get the x y and z component of V0 using theta and ...


1

The clearest way to make sense of any equation is to figure out the units. In this case, it's a bit ambiguous, but you know that velocity is m/h and that radius would be some kind of distance. v^2 is a good assumption in this case, but it is not immediately obvious why without knowing something about the units of the denominator. Just by looking at this, ...


0

Edit: Someone pointed out that R is in feet. Makes sense as well, and the rest stands. When in feet, the formula probably describes a tightest recommended curvature instead of a comfortable curvature. If solving from the formula the speed for this scandinavian location, it would be 30 mph or 48 km/h. The speed limit there is 40 km/h, so 48 is uncomfortable. ...



Top 50 recent answers are included