Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Custom Force to Match Object
#3
Thanks for the response! Excellent support here as usual Interesante







I was wondering if you could please post a good example of how to use the solver externalForces array. I tried the code below, but this is throwing a NullReferenceException runtime error on the for loop line.



Code:
    public ObiRope myRope; //this is assigned in Start()

    private void FixedUpdate()
    {

        for (int i = 0; i < myRope.solverIndices.Length; ++i)
            myRope.solver.externalForces[i] = myForce;

    }








In fact, this experiment below produced both a NullReferenceException runtime error, and the actual length of the array in the console Confundido




Code:
    private void FixedUpdate()
    {

        Debug.Log("myRope.solverIndices.Length: " + myRope.solverIndices.Length);



    }

NullReferenceException: Object reference not set to an instance of an object
ObiRopePlanetGravity.FixedUpdate () (at Assets/ObiRopePlanetGravity.cs:55)


myRope.solverIndices.Length: 10
UnityEngine.Debug:Log (object)
ObiRopePlanetGravity:FixedUpdate () (at Assets/ObiRopePlanetGravity.cs:55)
Reply


Messages In This Thread
Custom Force to Match Object - by docgonzzo - 25-10-2022, 12:31 AM
RE: Custom Force to Match Object - by josemendez - 25-10-2022, 07:21 AM
RE: Custom Force to Match Object - by docgonzzo - 26-10-2022, 12:22 AM
RE: Custom Force to Match Object - by josemendez - 26-10-2022, 07:52 AM
RE: Custom Force to Match Object - by docgonzzo - 27-10-2022, 12:06 AM
RE: Custom Force to Match Object - by josemendez - 27-10-2022, 07:39 AM