Game Development Community

Object Type question....

by Anthony Ayers · in Torque X 2D · 05/27/2008 (8:36 am) · 3 replies

Ok, so why when I do this....

TorqueObjectType typeZed = TorqueObjectDatabase.Instance.GetObjectType("zed");
T2DSceneObject zed = (T2DSceneObject)baseZedTemplate.Clone();
zed.ObjectType = typeZed;
zed.Position = new Vector2(-20, 20);
TorqueObjectDatabase.Instance.Register(zed);

...it is still not assigning a "name" to the zed.ObjectType??? It still says "Unkown"? In debug, I can see that the object type was looked up properly, and that the instance of the object has a name of "zed", but when I assign the object type to the new object, I get "Unknown"!!! Am I retarted???

thanks,
monty

#1
05/16/2009 (6:12 am)
I got same problem,

Can anybody help?

Thanks
SrkN
#2
08/29/2009 (3:30 am)
There must be a special way to do this. I say this because there is an actual method for testing if an object has a specific object type as seen in this thread:
http://www.garagegames.com/community/forums/viewthread/64038

There is probably a method to do what you need as well.
#3
08/29/2009 (4:19 pm)
There is no special way to do it - the way that Anthony was doing it is correct. However, if you look at zed.ObjectType it will *always* show 'unknown' as the name. The following is the code for the ObjectType get/set:

/// <summary>
        /// The TorqueObjectType for this object.
        /// </summary>
        public TorqueObjectType ObjectType
        {
            get
            {
                TorqueObjectType objType = new TorqueObjectType();
                objType._bits = _objectType;
                objType._typeName = "unknown";

                return objType;
            }
            set
            {
                _objectType = value._bits;

                if (Manager != null)
                    _objectType |= Manager.GenericObjectType._bits;
            }
        }

To actually check if the object is of type "zed" you need to use a method call like Randy says. The method is TestObjectType().