Example #1
1
    void Start()
    {
        GameObject capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
        capsule.transform.position.Set(1, 5, 2);
        capsule.AddComponent("Ridgidbody");

        PhysicMaterial material = new PhysicMaterial();
        material.bounciness = 1;
        capsule.collider.material = material;
    }
    public PhysicMaterialReplacer(Transform anchor, InteractionMaterial material) {
      _colliders = anchor.GetComponentsInChildren<Collider>(true);
      _originalMaterials = _colliders.Select(c => c.sharedMaterial).ToArray();

      switch (material.PhysicMaterialMode) {
        case InteractionMaterial.PhysicMaterialModeEnum.NoAction:
          _replacementMaterials = null;
          break;
        case InteractionMaterial.PhysicMaterialModeEnum.DuplicateExisting:
          _replacementMaterials = _originalMaterials.Select(m => {
            PhysicMaterial newMat;
            if (m == null) {
              newMat = new PhysicMaterial();
              newMat.name = "Grasping Material";
            } else {
              newMat = Object.Instantiate(m);
              newMat.name = m.name + " (Grasping Instance)";
            }
            newMat.bounciness = 0;
            return newMat;
          }).ToArray();
          break;
        case InteractionMaterial.PhysicMaterialModeEnum.Replace:
          _replacementMaterials = _originalMaterials.Select(m => material.ReplacementPhysicMaterial).ToArray();
          break;
      }
    }
Example #3
0
    public GameObject[] CollideWorld(Vector3 centre,float d, PhysicMaterial mat)
    {
        Vector3 pos = centre;
        Vector3 size = new Vector3(1f,1f,1f);
        float angle = 0;
        float step = Mathf.PI/360f*2f;
        GameObject[] objects = new GameObject[360];
        GameObject parent = new GameObject("parent");
        BoxCollider boxCollider = null;
        Vector3 sizeOfColl = new Vector3(1f,5f,3.5f);

            for(int i=0; i<360f; i++)
            {
                pos.x = centre.x + d* Mathf.Cos(angle);
                pos.z = centre.z + d* Mathf.Sin(angle);
                angle +=step;
                GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube);

                obj.transform.localScale = size;
                obj.transform.position = pos;
                ((BoxCollider)obj.transform.collider).size = sizeOfColl;
                ((BoxCollider)obj.transform.collider).material = mat;
                obj.transform.parent = parent.transform;

                objects[i] = obj;
            }
        return objects;
    }
 static public int get_dynamicFriction(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.dynamicFriction);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 public static int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.PhysicMaterial o;
         if(argc==1){
             o=new UnityEngine.PhysicMaterial();
             pushValue(l,true);
             pushValue(l,o);
             return 2;
         }
         else if(argc==2){
             System.String a1;
             checkType(l,2,out a1);
             o=new UnityEngine.PhysicMaterial(a1);
             pushValue(l,true);
             pushValue(l,o);
             return 2;
         }
         return error(l,"New object failed.");
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
 static public int set_bounciness(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.bounciness = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.PhysicMaterial o;
         if (argc == 1)
         {
             o = new UnityEngine.PhysicMaterial();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc == 2)
         {
             System.String a1;
             checkType(l, 2, out a1);
             o = new UnityEngine.PhysicMaterial(a1);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 void OnEnable()
 {
     // get relevant components
     playerRigidbody = GameObject.FindWithTag ("Player").GetComponent<Rigidbody> ();
     playerMovement = GameObject.FindWithTag ("Player").GetComponent<Movement> ();
     playerPMat = (PhysicMaterial) Resources.Load ("PhysicMaterials/Ball");
 }
 static public int set_frictionCombine(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.PhysicMaterial        self = (UnityEngine.PhysicMaterial)checkSelf(l);
         UnityEngine.PhysicMaterialCombine v;
         v = (UnityEngine.PhysicMaterialCombine)LuaDLL.luaL_checkinteger(l, 2);
         self.frictionCombine = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
        private void Awake()
        {
            // Create frictionless physmaterial for walls
            var material = new PhysicMaterial("Frictionless");
            material.staticFriction = 0f;
            material.dynamicFriction = 0f;
            material.frictionCombine = PhysicMaterialCombine.Minimum;
            material.bounceCombine = PhysicMaterialCombine.Minimum;
            material.bounciness = 0f;

            var surfaces = new BoxCollider[6];
            for (var i = 0; i < 6; i++)
            {
                var obj = new GameObject();
                obj.transform.SetParent(transform, false);
                var collider = obj.AddComponent<BoxCollider>();
                collider.sharedMaterial = material;
                surfaces[i] = collider;
            }
            var size = thickness / transform.localScale.magnitude;
            var offset = 0.5f + size / 2f;
            // Floor
            surfaces[0].size = new Vector3(1f, size, 1f);
            surfaces[0].transform.localPosition = new Vector3(0f, -offset, 0f);
            surfaces[0].name = "Floor";

            // Ceiling
            surfaces[1].size = new Vector3(1f, size, 1f);
            surfaces[1].transform.localPosition = new Vector3(0f, offset, 0f);
            surfaces[1].name = "Ceiling";

            // Wall Z-
            surfaces[2].size = new Vector3(1f, 1f, size);
            surfaces[2].transform.localPosition = new Vector3(0f, 0f, -offset);
            surfaces[2].name = "Wall Z-";

            // Wall Z+
            surfaces[3].size = new Vector3(1f, 1f, size);
            surfaces[3].transform.localPosition = new Vector3(0f, 0f, offset);
            surfaces[3].name = "Wall Z+";

            // Wall X-
            surfaces[4].size = new Vector3(size, 1f, 1f);
            surfaces[4].transform.localPosition = new Vector3(-offset, 0f, 0f);
            surfaces[4].name = "Wall X-";

            // Wall X+
            surfaces[5].size = new Vector3(size, 1f, 1f);
            surfaces[5].transform.localPosition = new Vector3(offset, 0f, 0f);
            surfaces[5].name = "Wall X+";

            if (useLayer)
            {
                for (int i = 0; i < surfaces.Length; i++)
                {
                    surfaces[i].gameObject.layer = gameObject.layer;
                }
            }
        }
Example #11
0
 static public int set_frictionDirection2(IntPtr l)
 {
     UnityEngine.PhysicMaterial o = (UnityEngine.PhysicMaterial)checkSelf(l);
     UnityEngine.Vector3        v;
     checkType(l, 2, out v);
     o.frictionDirection2 = v;
     return(0);
 }
Example #12
0
 static public int set_bounceCombine(IntPtr l)
 {
     UnityEngine.PhysicMaterial        o = (UnityEngine.PhysicMaterial)checkSelf(l);
     UnityEngine.PhysicMaterialCombine v;
     checkEnum(l, 2, out v);
     o.bounceCombine = v;
     return(0);
 }
Example #13
0
        public bool UpdateCollider(CGColliderEnum mode, bool convex, PhysicMaterial material)
        {
            if (Collider == null)
            {
                switch (mode)
                {
                    case CGColliderEnum.Mesh:
                        if (canAddMeshCollider(Filter.sharedMesh.bounds))
                        {
                            var mc = gameObject.AddComponent<MeshCollider>();
                            mc.convex = convex;
                            mCollider = mc;
                        }
                        break;
                    case CGColliderEnum.Box:
                        gameObject.AddComponent<BoxCollider>();
                        break;
                    case CGColliderEnum.Sphere:
                        gameObject.AddComponent<SphereCollider>();
                        break;
                }
            }

            if (Collider != null)
            {
                switch (mode)
                {
                    case CGColliderEnum.Mesh:
                        var mc = Collider as MeshCollider;
                        mc.sharedMesh = null;
                        if (!canAddMeshCollider(Filter.sharedMesh.bounds))
                            return false;
                        try
                        {
                            mc.sharedMesh = Filter.sharedMesh;
                        }
                        catch
                        {
                            return false;
                        }
                        break;
                    case CGColliderEnum.Box:
                        var bc = Collider as BoxCollider;
                        bc.center = Filter.sharedMesh.bounds.center;
                        bc.size = Filter.sharedMesh.bounds.size;
                        break;
                    case CGColliderEnum.Sphere:
                        var sc = Collider as SphereCollider;
                        sc.center = Filter.sharedMesh.bounds.center;
                        sc.radius = Filter.sharedMesh.bounds.extents.magnitude;
                        break;
                }
                Collider.material = material;
            }
            return true;

            
        }
Example #14
0
    static public int set_staticFriction(IntPtr l)
    {
        UnityEngine.PhysicMaterial o = (UnityEngine.PhysicMaterial)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.staticFriction = v;
        return(0);
    }
Example #15
0
    static public int set_bounciness(IntPtr l)
    {
        UnityEngine.PhysicMaterial o = (UnityEngine.PhysicMaterial)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.bounciness = v;
        return(0);
    }
Example #16
0
 public override void InitPhysics()
 {
     bodyCollider = gameObject.AddComponent<BoxCollider>();
     bodyCollider.size=new Vector3(Size.x * FPhysics.POINTS_TO_METERS,Size.y * FPhysics.POINTS_TO_METERS,64);
     PhysicMaterial mat = new PhysicMaterial();
     mat.bounciness = Bounciness;
     mat.dynamicFriction = FrictionDyn;
     mat.staticFriction = FrictionSta;
     mat.frictionCombine = PhysicMaterialCombine.Maximum;
 }
 public void Start()
 {
     Controller = gameObject.AddComponent<CharacterController>();
     Controller.radius = .25f;
     Controller.height = 1;
     MainCamera = Camera.main;
     MainCamera.nearClipPlane = .1f;
     gameObject.AddComponent<MouseLook>();
     BouncyMaterial = (PhysicMaterial)Resources.Load("BouncySphereMaterial");
 }
Example #18
0
    void Start()
    {
        LavaMaterial = Resources.Load<Material>("Lava_Color");
        IceMaterial = Resources.Load<Material>("Ice_Color");
        WaterMaterial = Resources.Load<Material>("Water_Color");

        IcePhysics = Resources.Load<PhysicMaterial>("ice_physics");

        this.renderer.material = IceMaterial;
    }
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.PhysicMaterial physicMaterial = (UnityEngine.PhysicMaterial)value;
     writer.WriteProperty("dynamicFriction", physicMaterial.dynamicFriction);
     writer.WriteProperty("staticFriction", physicMaterial.staticFriction);
     writer.WriteProperty("bounciness", physicMaterial.bounciness);
     writer.WriteProperty("frictionCombine", physicMaterial.frictionCombine);
     writer.WriteProperty("bounceCombine", physicMaterial.bounceCombine);
     writer.WriteProperty("name", physicMaterial.name);
     writer.WriteProperty("hideFlags", physicMaterial.hideFlags);
 }
 static public int get_bounceCombine(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushEnum(l, (int)self.bounceCombine);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_bounciness(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushValue(l, self.bounciness);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_frictionCombine(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.frictionCombine);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_staticFriction(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.staticFriction);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #24
0
 public static SoundPrefab.Materials MaterialPhysicsToSound(PhysicMaterial mat)
 {
     SoundPrefab.Materials result;
     if (mat != null && materialNames.TryGetValue(mat.name, out result))
     {
         return result;
     }
     else
     {
         return SoundPrefab.Materials.None;
     }
 }
Example #25
0
 private SurfaceSound _GetCurrentSurface(PhysicMaterial currentMaterial)
 {
     SurfaceSound surfaceSound;
     if(currentMaterial != null && surfaceTable != null && surfaceTable.TryGetValue(currentMaterial, out surfaceSound))
     {
         return surfaceSound;
     }
     else
     {
         return DefaultSounds;
     }
 }
Example #26
0
 static public int get_staticFriction(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushValue(l, self.staticFriction);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #27
0
 static public int get_frictionCombine(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         pushEnum(l, (int)self.frictionCombine);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #28
0
	// Use this for initialization
	void Start ()
    {
        ServiceLocator.GetGameManager().winOnTimeOut = true;

		PhysicMaterial physicMat = new PhysicMaterial();
		GetComponent<Collider>().material = physicMat;
		physicMat.bounciness = 0;
		physicMat.dynamicFriction = 0.2f;
        ServiceLocator.GetSoundSystem().PlayBackgroundMusic("runner");
        ServiceLocator.GetSoundSystem().PlaySound("hintRunner");
        rb = GetComponent<Rigidbody>();
    }
Example #29
0
    void Start()
    {
        float bouncyAmount = 0.5f;
        Color myColor = Color.red;

        gameObject.AddComponent("Rigidbody");

        PhysicMaterial material = new PhysicMaterial();
        material.bounciness = bouncyAmount;
        gameObject.collider.material = material;

        gameObject.renderer.material.color = myColor;
    }
 static public int set_staticFriction(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.staticFriction = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #31
0
	void Start()
	{
		//Set static variables
		wheelCastMaskStatic = wheelCastMask;
		groundMaskStatic = groundMask;
		damageMaskStatic = damageMask;
		ignoreWheelCastLayer = LayerMask.NameToLayer("Ignore Wheel Cast");
		frictionlessMatStatic = frictionlessMat;
		tireMarkLengthStatic = Mathf.Max(tireMarkLength, 2);
		tireMarkGapStatic = tireMarkGap;
		tireMarkHeightStatic = tireMarkHeight;
		tireFadeTimeStatic = tireFadeTime;
	}
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial o;
         o = new UnityEngine.PhysicMaterial();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_bounceCombine(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial        self = (UnityEngine.PhysicMaterial)checkSelf(l);
         UnityEngine.PhysicMaterialCombine v;
         checkEnum(l, 2, out v);
         self.bounceCombine = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_frictionCombine(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial        self = (UnityEngine.PhysicMaterial)checkSelf(l);
         UnityEngine.PhysicMaterialCombine v;
         checkEnum(l, 2, out v);
         self.frictionCombine = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #35
0
 static public int set_frictionCombine(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial        self = (UnityEngine.PhysicMaterial)checkSelf(l);
         UnityEngine.PhysicMaterialCombine v;
         checkEnum(l, 2, out v);
         self.frictionCombine = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int set_bounciness(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.bounciness = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #37
0
 static public int set_frictionDirection2(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         UnityEngine.Vector3        v;
         checkType(l, 2, out v);
         self.frictionDirection2 = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
    void Start()
    {
        currentMass = gameObject.GetComponent<Rigidbody>().mass;
        playerPhyscMat = gameObject.GetComponent<Collider>().material;
        skinnedRenderer = gameObject.GetComponent<SkinnedMeshRenderer>();
        plyrMaterial = skinnedRenderer.material;

        // Starting Color
        plyrMaterial.color = LightColor;

        // Get Ui Elements
        MassBar = GameObject.Find("MassBar").GetComponent<Image>();
        BounceBar = GameObject.Find("BounceBar").GetComponent<Image>();
    }
Example #39
0
 static public int set_dynamicFriction(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.dynamicFriction = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #40
0
 static public int set_frictionDirection2(IntPtr l)
 {
     try {
         UnityEngine.PhysicMaterial self = (UnityEngine.PhysicMaterial)checkSelf(l);
         UnityEngine.Vector3        v;
         checkType(l, 2, out v);
         self.frictionDirection2 = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #41
0
		public VoxelSubstance(
			string name,
			Material renderMaterial,
			Material blendMaterial,
			PhysicMaterial physicsMaterial
//			float strength, float pliability, float conductivity
			) {
			this.name = name;
			this.renderMaterial = renderMaterial;
			this.blendMaterial = blendMaterial;
			this.physicsMaterial = physicsMaterial;
//			this.strength = strength;
//			this.pliability = pliability;
//			this.conductivity = conductivity;
		}
 static void PhysicMaterial_bounciness(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.PhysicMaterial _this = (UnityEngine.PhysicMaterial)vc.csObj;
         var result = _this.bounciness;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.PhysicMaterial _this = (UnityEngine.PhysicMaterial)vc.csObj;
         _this.bounciness = arg0;
     }
 }
 static void Collider_material(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Collider _this = (UnityEngine.Collider)vc.csObj;
         var result = _this.material;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.PhysicMaterial arg0  = (UnityEngine.PhysicMaterial)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.Collider       _this = (UnityEngine.Collider)vc.csObj;
         _this.material = arg0;
     }
 }
Example #44
0
    static int QPYX_set_sharedMaterial_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.Collider QPYX_obj_YXQP = (UnityEngine.Collider)QPYX_o_YXQP;
            UnityEngine.PhysicMaterial QPYX_arg0_YXQP = (UnityEngine.PhysicMaterial)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.PhysicMaterial));
            QPYX_obj_YXQP.sharedMaterial = QPYX_arg0_YXQP;
            return(0);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index sharedMaterial on a nil value"));
        }
    }
Example #45
0
    static int QPYX_get_sharedMaterial_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.Collider QPYX_obj_YXQP = (UnityEngine.Collider)QPYX_o_YXQP;
            UnityEngine.PhysicMaterial QPYX_ret_YXQP = QPYX_obj_YXQP.sharedMaterial;
            ToLua.PushSealed(L_YXQP, QPYX_ret_YXQP);
            return(1);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index sharedMaterial on a nil value"));
        }
    }
Example #46
0
 public override void InitPhysics()
 {
     Rigidbody rb = gameObject.AddComponent<Rigidbody>();
     rb.constraints =  RigidbodyConstraints.FreezeRotation;
     rb.angularDrag = AngularDrag;
     rb.mass = Mass;
     bodyCollider = gameObject.AddComponent<BoxCollider>();
     bodyCollider.size=new Vector3(Size.x * FPhysics.POINTS_TO_METERS,Size.y* FPhysics.POINTS_TO_METERS,32);
     PhysicMaterial mat = new PhysicMaterial();
     mat.bounciness = Bounciness;
     mat.dynamicFriction = FrictionDyn;
     mat.staticFriction = FrictionSta;
     mat.frictionCombine = PhysicMaterialCombine.Maximum;
     collider.material = mat;
 }
 static void PhysicMaterial_bounceCombine(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.PhysicMaterial _this = (UnityEngine.PhysicMaterial)vc.csObj;
         var result = _this.bounceCombine;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.PhysicMaterialCombine arg0  = (UnityEngine.PhysicMaterialCombine)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.PhysicMaterial        _this = (UnityEngine.PhysicMaterial)vc.csObj;
         _this.bounceCombine = arg0;
     }
 }
 static void PhysicMaterial_frictionDirection2(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.PhysicMaterial _this = (UnityEngine.PhysicMaterial)vc.csObj;
         var result = _this.frictionDirection2;
         JSApi.setVector3S((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Vector3        arg0  = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
         UnityEngine.PhysicMaterial _this = (UnityEngine.PhysicMaterial)vc.csObj;
         _this.frictionDirection2 = arg0;
     }
 }
Example #49
0
    void Awake()
    {
        rgbody = GetComponent<Rigidbody>();
        capsuleCollider = GetComponent<CapsuleCollider>();
        animator = GetComponent<Animator>();

        if (rgbody == null) throw new MissingReferenceException("Rigidbody tidak ditemukan");
        if (capsuleCollider == null) throw new MissingReferenceException("Capsule Collider tidak ditemukan");
        if (animator == null) throw new MissingReferenceException("Animator tidak ditemukan");

        PhysicMaterial material = new PhysicMaterial();
        material.bounciness = 0;
        material.staticFriction = 0;
        material.dynamicFriction = 0;

        capsuleCollider.material = material;
    }
Example #50
0
    //**********************************************************************************//
    // INITIAL SETUP 																	//
    // prepare the initial information for capsule collider, physics materials, etc...  //
    //**********************************************************************************//
    public void InitialSetup()
	{
		animator = GetComponent<Animator>();
        shootables = new List<Transform>();
        // better sync of animations like quickTurn180
        animator.updateMode = AnimatorUpdateMode.AnimatePhysics;
        communication = new SerialCommunication();
		tpCamera = TPCamera.instance;
        CollectShootableBodyParts(transform);
		
		if (hud == null) Debug.Log("Missing HUDController, please assign on ThirdPersonController");
				
		// prevents the collider from slipping on ramps
		frictionPhysics = new PhysicMaterial();
		frictionPhysics.name = "frictionPhysics";
		frictionPhysics.staticFriction = 0.6f;
		frictionPhysics.dynamicFriction = 0.6f;
		
		// default physics 
		defaultPhysics = new PhysicMaterial();
		defaultPhysics.name = "defaultPhysics";
		defaultPhysics.staticFriction = 0f;
		defaultPhysics.dynamicFriction = 0f;
		
		// rigidbody info
		_rigidbody = GetComponent<Rigidbody> ();
		
		// capsule collider 
		capsuleCollider = GetComponent<CapsuleCollider>();
		
		// save your collider preferences 
		colliderCenter = GetComponent<CapsuleCollider>().center;
		colliderRadius = GetComponent<CapsuleCollider>().radius;
		colliderHeight = GetComponent<CapsuleCollider>().height;
		
		CreateBonesToCurve();

		currentHealth = startingHealth;
		currentStamina = startingStamina;		
		
		if(hud == null)
			return;
		
		hud.damageImage.color = new Color(0f, 0f, 0f, 0f);
	}
	public static matID GetMaterialID( PhysicMaterial physMat )
	{
		if ( physMat == null )
			return matID.CONCRETE;

		Debug.Log ( physMat.name );

		if ( physMat == null )
			return matID.CONCRETE;
		else if ( string.Equals( physMat.name, "Concrete" )	)
			return matID.CONCRETE;
		else if ( string.Equals( physMat.name, "Dirt" )	||	string.Equals( physMat.name, "Grass" )		)
			return matID.DIRT;
		else if ( string.Equals( physMat.name, "Sand" )	)
			return matID.SAND;
		else if ( string.Equals( physMat.name, "Stone" )	)
			return matID.STONE;
		else if ( string.Equals( physMat.name, "Brick" )	)
			return matID.BRICK;
		else if ( string.Equals( physMat.name, "Mud" )	)
			return matID.MUD;
		else if ( string.Equals( physMat.name, "Flesh" )	)
			return matID.FLESH;
		else if ( string.Equals( physMat.name, "Foliage" )	)
			return matID.FOLIAGE;
		else if ( string.Equals( physMat.name, "Glass" ) || string.Equals( physMat.name, "CarGlass" )	)
			return matID.GLASS;	
		else if ( string.Equals( physMat.name, "Metal" ) || string.Equals( physMat.name, "CarMaterial" )	)
			return matID.METAL;
		else if ( string.Equals( physMat.name, "Paper" )	)
			return matID.PAPER;
		else if ( string.Equals( physMat.name, "Plaster" )	)
			return matID.PLASTER;
		else if ( string.Equals( physMat.name, "Plastic" )	)
			return matID.PLASTIC;
		else if ( string.Equals( physMat.name, "Water" )	)
			return matID.WATER;
		else if ( string.Equals( physMat.name, "Wood" )	)
			return matID.WOOD;
		else
			return matID.CONCRETE;
	}
Example #52
0
	private void TestSpawn()
	{
		GameObject g = GameObject.CreatePrimitive(PrimitiveType.Cube);
		//Destroy(g.GetComponent<BoxCollider>());
		g.name = "Test";
		PhysicMaterial pm = new PhysicMaterial("BOUNCE");
		pm.bounciness = 0.8f;
		g.GetComponent<BoxCollider>().material = pm;
		g.transform.SetParent(transform, false);
		g.transform.localPosition = RandomPos();

		Rigidbody r = g.AddComponent<Rigidbody>();

		r.velocity = new Vector3(0, 0, -5);
		r.useGravity = false;

		g.AddComponent<EnemyBase>();

		Destroy(g, 20f);
	}
Example #53
0
		protected virtual void Start() {
			capsule = GetComponent<Collider>() as CapsuleCollider;
			r = GetComponent<Rigidbody>();

			// Store the collider volume
			originalHeight = capsule.height;
			originalCenter = capsule.center;

			// Physics materials
			zeroFrictionMaterial = new PhysicMaterial();
			zeroFrictionMaterial.dynamicFriction = 0f;
			zeroFrictionMaterial.staticFriction = 0f;
			zeroFrictionMaterial.frictionCombine = PhysicMaterialCombine.Minimum;
			zeroFrictionMaterial.bounciness = 0f;
			zeroFrictionMaterial.bounceCombine = PhysicMaterialCombine.Minimum;

			highFrictionMaterial = new PhysicMaterial();

			// Making sure rigidbody rotation is fixed
			r.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
		}
Example #54
0
	void Awake()
	{
		rigid = GetComponent<Rigidbody>();
		//set up rigidbody constraints
		rigid.interpolation = RigidbodyInterpolation.Interpolate;
		if(sidescroller)
			rigid.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
		else
			rigid.constraints = RigidbodyConstraints.FreezeRotation;
		//add frictionless physics material
		if(GetComponent<Collider>().material.name == "Default (Instance)")
		{
			PhysicMaterial pMat = new PhysicMaterial();
			pMat.name = "Frictionless";
			pMat.frictionCombine = PhysicMaterialCombine.Multiply;
			pMat.bounceCombine = PhysicMaterialCombine.Multiply;
			pMat.dynamicFriction = 0f;
			pMat.staticFriction = 0f;
			GetComponent<Collider>().material = pMat;
			Debug.LogWarning("No physics material found for CharacterMotor, a frictionless one has been created and assigned", transform);
		}
	}
Example #55
0
 public void SetPhysicsMaterial(PhysicMaterial physicsMaterial, RageSpline caller)
 {
     if (this.physicsMaterial != physicsMaterial)
     {
         this.physicsMaterial = physicsMaterial;
         RefreshAllRageSplinesWithThisStyle(caller);
     }
 }
Example #56
0
 public void GetStyleFromRageSpline(RageSpline rageSpline)
 {
     this.antiAliasingWidth = rageSpline.antiAliasingWidth;
     this.colliderZDepth = rageSpline.colliderZDepth;
     this.createPhysicsInEditor = rageSpline.createPhysicsInEditor;
     this.emboss = rageSpline.emboss;
     this.embossAngle = rageSpline.embossAngle;
     this.embossColor1 = rageSpline.embossColor1;
     this.embossColor2 = rageSpline.embossColor2;
     this.embossCurveSmoothness = rageSpline.embossCurveSmoothness;
     this.embossOffset = rageSpline.embossOffset;
     this.embossSize = rageSpline.embossSize;
     this.fill = rageSpline.fill;
     this.fillColor1 = rageSpline.fillColor1;
     this.fillColor2 = rageSpline.fillColor2;
     this.gradientAngle = rageSpline.gradientAngle;
     this.gradientOffset = rageSpline.gradientOffset;
     this.gradientScale = rageSpline.gradientScale;
     this.outline = rageSpline.outline;
     this.outlineColor1 = rageSpline.outlineColor1;
     this.outlineColor2 = rageSpline.outlineColor2;
     this.outlineTexturingScale = rageSpline.outlineTexturingScale;
     this.outlineWidth = rageSpline.OutlineWidth;
     this.outlineGradient = rageSpline.outlineGradient;
     this.outlineNormalOffset = rageSpline.outlineNormalOffset;
     this.corners = rageSpline.corners;
     this.physics = rageSpline.physics;
     this.physicsColliderCount = rageSpline.physicsColliderCount;
     this.physicsMaterial = rageSpline.physicsMaterial;
     this.textureAngle = rageSpline.textureAngle;
     this.textureAngle2 = rageSpline.textureAngle2;
     this.textureOffset = rageSpline.textureOffset;
     this.textureOffset2 = rageSpline.textureOffset2;
     this.textureScale = rageSpline.textureScale;
     this.textureScale2 = rageSpline.textureScale2;
     this.UVMapping1 = rageSpline.UVMapping1;
     this.UVMapping2 = rageSpline.UVMapping2;
     this.vertexCount = rageSpline.vertexCount;
 }
Example #57
0
	/// <summary>
	/// Clears the cut materials. Called when user hits button on road editor inspector gui.
	/// </summary>
	public void ClearCuts(){
		RoadCut_world_Mats = null;
		ShoulderCutR_world_Mats = null;
		ShoulderCutL_world_Mats = null;
		RoadCut_marker_Mats = null;
		ShoulderCutR_marker_Mats = null;
		ShoulderCutL_marker_Mats = null;
		RoadCut_PhysicMat = null;
		ShoulderCutR_PhysicMat = null;
		ShoulderCutL_PhysicMat = null;
	}
Example #58
0
 void OnLand(PhysicMaterial currentMaterial)
 {
     SurfaceSound surfaceSound = _GetCurrentSurface(currentMaterial);
     SECTR_AudioSystem.Play(surfaceSound.LandCue, transform.position, false);
 }
Example #59
0
        //**********************************************************************************//
        // INITIAL SETUP 																	//
        // prepare the initial information for capsule collider, physics materials, etc...  //
        //**********************************************************************************//
        public void InitialSetup()
        {
            animator = GetComponent<Animator>();

            tpCamera = TPCamera.instance;
            // create a offset pivot to the character, to align camera position when transition to ragdoll
            var hips = animator.GetBoneTransform(HumanBodyBones.Hips);
            offSetPivot = Vector3.Distance(transform.position, hips.position);
            tpCamera.offSetPlayerPivot = offSetPivot;

            if (hud == null) Debug.Log("Missing HUDController, please assign on ThirdPersonController");

            // prevents the collider from slipping on ramps
            frictionPhysics = new PhysicMaterial();
            frictionPhysics.name = "frictionPhysics";
            frictionPhysics.staticFriction = 0.6f;
            frictionPhysics.dynamicFriction = 0.6f;

            // default physics
            defaultPhysics = new PhysicMaterial();
            defaultPhysics.name = "defaultPhysics";
            defaultPhysics.staticFriction = 0f;
            defaultPhysics.dynamicFriction = 0f;

            // rigidbody info
            _rigidbody = GetComponent<Rigidbody>();

            // capsule collider
            capsuleCollider = GetComponent<CapsuleCollider>();

            // save your collider preferences
            colliderCenter = GetComponent<CapsuleCollider>().center;
            colliderRadius = GetComponent<CapsuleCollider>().radius;
            colliderHeight = GetComponent<CapsuleCollider>().height;

            currentHealth = startingHealth;
            currentStamina = startingStamina;

            if (hud == null)
                return;

            hud.damageImage.color = new Color(0f, 0f, 0f, 0f);
        }
Example #60
0
    public void SetPhysicsMaterial(PhysicMaterial physicsMaterial)
    {
        this.physicsMaterial = physicsMaterial;

        if (style != null)
        {
            style.SetPhysicsMaterial(physicsMaterial, this);
        }
    }