Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Rope Grabbing
#4
Hi Eddy,

Your RopeGrabber script looks like this:

Code:
public class RopeGrabber : MonoBehaviour
{
    // Start is called before the first frame update
    ObiContactGrabber obigrab;
    void Start()
    {
        obigrab.Grab();
    }

    // Update is called once per frame
    void Update()
    {
        obigrab.Grab();
    }
}

Entering play mode results in a NullReferenceException right away, because the "obigrab" variable is null.

"obigrab" is not public (so you can't assign it in the inspector, or change its value from another place) and you're not assigning any value to it at runtime either, so this script can't possibly work. Either make the variable public and assign the ObiContactGrabber to it by dragging the component into the inspector slot, or use GetComponent<T> at runtime to get a reference to the ObiContactGrabber.

Also, calling the Grab() method every frame is probably not a good idea.

I'd advise to get familiar with the basics of Unity and C# programming before using Obi, otherwise you're in for a lot of frustration. Obi is an advanced engine that assumes basic physics and math knowledge (time stepping, vector and matrix algebra, use of forces/accelerations/impulses, etc) as well as intermediate programming skills.

cheers!
Reply


Messages In This Thread
Basic Rope Grabbing - by eddy_vr - 31-05-2021, 11:05 AM
RE: Basic Rope Grabbing - by josemendez - 31-05-2021, 01:02 PM
RE: Basic Rope Grabbing - by eddy_vr - 31-05-2021, 11:23 PM
RE: Basic Rope Grabbing - by josemendez - 01-06-2021, 08:28 AM
RE: Basic Rope Grabbing - by eddy_vr - 06-06-2021, 04:20 PM