Quantcast
Viewing all articles
Browse latest Browse all 107

Add force help needed

hey guys i really need help. i am trying to make swimable underwater, but i am really stuck. i am missing something in my code. my character is the _pc object my water plane is _water the are no errors how ever this does not work at all not even the debug. any suggestions would be great...
using UnityEngine;
using System.Collections;

public class gravity : MonoBehaviour {
	public GameObject _pc;	public GameObject _water;		void Start() {        		_water.collider.isTrigger = true;	}		void OnTriggerEnter(Collider _water) {		if (_pc.rigidbody == true)	//		Debug.Log ("we are in the water");			_pc.rigidbody.useGravity = false;			}	void OnTriggerExit(Collider _water) {		if (_pc.rigidbody)			Debug.Log ("we are out of the water");			_pc.rigidbody.useGravity = true;	}	 void FixedUpdate() {		if(_water.collider.isTrigger == true){			_pc.rigidbody.AddForce(0, 50, 0);		}	}
}

Viewing all articles
Browse latest Browse all 107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>