logo
down
shadow

Spin physics issue in Unity3d


Spin physics issue in Unity3d

By : Shailesh
Date : November 19 2020, 03:59 PM
Hope this helps Finally I got the solution. Actually I have used the torque after adding force so it is not going at right direction as per spin. But it should be like Add Torque First and then Add Force at Position.
Here is the sample code. I hope this will help little bit other people regarding spin physics in unity3d.
code :
using UnityEngine;
using System.Collections;

public class CueBall : MonoBehaviour {

    private enum SPIN{ nospin, leftspin,rightspin,topspin,bottomspin};

    private SPIN currentSpin = SPIN.topspin;

    private float cueStrength = 1000.0f;
    public Transform cueStick;

    // Use this for initialization
    void Start () {

        rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;

    }

    // Update is called once per frame
    void FixedUpdate () {


        if(Input.GetMouseButtonDown(0)){

                gameObject.rigidbody.drag = 0.6f;
                gameObject.rigidbody.mass = 1.2f;
                gameObject.rigidbody.angularDrag = 1.5f; 

            switch(currentSpin){

            case SPIN.topspin :

                    rigidbody.AddTorque(Vector3.back * cueStrength );
                    rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);

                    break;

            case SPIN.bottomspin:

                    rigidbody.AddTorque(Vector3.forward * cueStrength );
                    rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);

                    break;
            case SPIN.leftspin:

                    rigidbody.AddTorque(Vector3.up * cueStrength);
                    rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);

                break;
            case SPIN.rightspin:

                    rigidbody.AddTorque(Vector3.down * cueStrength );
                    rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);

                break;
            default : // no spin
                    // no required torque
                    rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);
                break;
            }

        }

    }
}


Share : facebook icon twitter icon
Issue with removing physics body from physics world (spritekit)

Issue with removing physics body from physics world (spritekit)


By : Amro A.
Date : March 29 2020, 07:55 AM
hop of those help? I'm not sure if I completely understand, but if you're looking for a way of removing your sprites upon collision, you have to access each physics body's node property, and call its removeFromParent function.
code :
[contact.bodyA.node removeFromParent];
[contact.bodyB.node removeFromParent];
2 Wheeled Vehicles (Physics in Unity3D)

2 Wheeled Vehicles (Physics in Unity3D)


By : Ankit Agrawal
Date : March 29 2020, 07:55 AM
This might help you Ok, I'll add an answer here (although its my own question) as I have seen a couple of posts asking similar things. Even if you are creating a vehicle with 2 dominent wheels (like a little robot or a Britenberg vehicle) you should still add small wheels to the front or back for stability (think of them as casters). On these caster wheels, turn the stiffness factor for the forwards and sideways friction down to 0. On your main drive wheels, turn the sideways friction stiffness factor down to 0.5
This allows the vehicle to skid steer.
Unity3D Physics.Raycast() never true

Unity3D Physics.Raycast() never true


By : Dans_account
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Look into Physics2D.Raycast. As far as I am aware, Physics.Raycast will not work with 2D colliders. You must use Physics2D.Raycast instead.
Can i take a model i created in blender and spin/rotate it in unity3d?

Can i take a model i created in blender and spin/rotate it in unity3d?


By : coolpep karthick
Date : March 29 2020, 07:55 AM
I wish this helpful for you I'm creating a model in blender: ,
Option 1: Animate it in Blender
Ignore physics after collision in unity3d(2d)

Ignore physics after collision in unity3d(2d)


By : ImranAhmed
Date : March 29 2020, 07:55 AM
With these it helps
I need to get OnCollisionEnter2d event, but i dont need to automatically change speed and direction, because i want to do it manually
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org