Esempio n. 1
0
        protected override bool Initialize()
        {
            if (Wire == null)
            {
                Debug.LogWarning("Wire not assigned to winch. Winch invalid and ignored.", this);
                return(false);
            }

            WireRouteNode winchNode = Wire.Route.FirstOrDefault(node => node.Winch == this);

            if (winchNode == null)
            {
                Debug.LogWarning("Unable to initialize winch - no winch node assigned.", this);
                return(false);
            }

            RigidBody rb = winchNode.Parent != null?winchNode.Parent.GetInitializedComponentInParent <RigidBody>() : null;

            if (rb == null)
            {
                Native = new agxWire.WireWinchController(null, winchNode.Position.ToHandedVec3(), (winchNode.Rotation * Vector3.forward).ToHandedVec3(), PulledInLength);
            }
            else
            {
                Native = new agxWire.WireWinchController(rb.Native, winchNode.CalculateLocalPosition(rb.gameObject).ToHandedVec3(), (winchNode.CalculateLocalRotation(rb.gameObject) * Vector3.forward).ToHandedVec3());
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Construct a route node given type, parent game object, local position to parent and
        /// local rotation to parent.
        /// </summary>
        /// <param name="type">Node type.</param>
        /// <param name="parent">Parent game object - world if null.</param>
        /// <param name="localPosition">Position in parent frame. If parent is null this is the position in world frame.</param>
        /// <param name="localRotation">Rotation in parent frame. If parent is null this is the rotation in world frame.</param>
        /// <returns>Wire route node instance.</returns>
        public static WireRouteNode Create(Wire.NodeType type       = Wire.NodeType.BodyFixedNode,
                                           GameObject parent        = null,
                                           Vector3 localPosition    = default(Vector3),
                                           Quaternion localRotation = default(Quaternion))
        {
            WireRouteNode node = Create <WireRouteNode>(parent, localPosition, localRotation);

            node.Type = type;

            return(node);
        }