Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Addition of Obi Collider
#1
Hello.

This is very basic question, but I cannot add Obi collider by AddComponent.
My code is.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ManSetting : MonoBehaviour
{
    public GameObject man;
    // Start is called before the first frame update
    void Start()
    {
        man.AddComponent<MeshCollider>();
        man.AddComponent<ObiCollider>();
    }
}

However, error massage is displayed like the image.
Reply
#2
(29-03-2019, 09:12 AM)Richard Wrote: Hello.

This is very basic question, but I cannot add Obi collider by AddComponent.
My code is.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ManSetting : MonoBehaviour
{
    public GameObject man;
    // Start is called before the first frame update
    void Start()
    {
        man.AddComponent<MeshCollider>();
        man.AddComponent<ObiCollider>();
    }
}

However, error massage is displayed like the image.

You forgot to include the Obi library. Add "using Obi;" to other usings in the top of the script.
Reply
#3
(29-03-2019, 09:18 AM)Evgenius Wrote: You forgot to include the Obi library. Add "using Obi;" to other usings in the top of the script.

That does not solve error. What is the other error?
Reply
#4
(29-03-2019, 09:50 AM)Richard Wrote: That does not solve error. What is the other error?

I can't see the log of the second error. Show the log and the string of code it's linked to.
Reply
#5
(29-03-2019, 09:53 AM)Evgenius Wrote: I can't see the log of the second error. Show the log and the string of code it's linked to.

Second one is:
Assets\ManSetting.cs(12,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Reply
#6
(29-03-2019, 10:03 AM)Richard Wrote: Second one is:
Assets\ManSetting.cs(12,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

And what about code?
Reply
#7
(29-03-2019, 10:07 AM)Evgenius Wrote: And what about code?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

public class ManSetting : MonoBehaviour
{
    public GameObject man;
    
    void Start()
    {
        man.AddComponent<MeshCollider>();
        man.AddComponent<ObiCollider>();
    }

    // Update is called once per frame
    void Update()
    {
        Transform myTransform = this.transform;
        
        Vector3 localScale = myTransform.localScale;

    }
}
Reply
#8
(29-03-2019, 10:14 AM)Richard Wrote: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

public class ManSetting : MonoBehaviour
{
    public GameObject man;
    
    void Start()
    {
        man.AddComponent<MeshCollider>();
        man.AddComponent<ObiCollider>();
    }

    // Update is called once per frame
    void Update()
    {
        Transform myTransform = this.transform;
        
        Vector3 localScale = myTransform.localScale;

    }
}

I copied your script to my project and got no errors. Write the exact code string that error is linked to.

(P.S., caching transform is good practice, but you're doing it wrong. Caching transform every update makes no sense and will do you no good.)
Reply