- Home /
I can't make this more reliable
I'm trying to make it so you can jump unless you are touching something, but so far this isnt reliable and it turns off sometimes when you are touching different parts (its in a javascript in the object your suppose to move)
function OnCollisionEnter2D(coll : Collision2D) {
touching = true;
}
function OnCollisionExit2D(coll : Collision2D) {
touching = false;
}
Isn't there a function like OnCollisionStay2D or something?
Yes, there is. (http://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.OnCollisionStay2D.html) Wrote this quite quickly.
The solution is also in c# not in javascript as OP requested (so not marked as potential answer). To convert static for a class would be some javascripty thing, something like this might be the way to do it: http://stackoverflow.com/questions/1535631/static-variables-in-javascript
Your answer
Follow this Question
Related Questions
Unusual multitouch behavior (Android) 3 Answers
Add limitation in Finger gesture package for touch 0 Answers
Show text on colision 2 Answers
Check every frame if Collider touch each other 2 Answers
Check if touching,Statement for touching 0 Answers