Hello guys, I’ve been facing a problem, I am sure that most of you played “Doodle Jump” or similar games on the iphone\ipod, in these games, the character jumps through the object it should collide with, but it passes through from below, but does not pass through from above, you can see what i mean roughly demonstrated in this pic i made.
so the character jumps , he passes through the object, but when he reaches his jump height and comes down, he collides with the same object and stands on it, how is that possible in unity iphone?
knowing that character is a “CharacterController” , and the object is just a mesh with a box collider and not a rigidbody…
the method i thought of :
making the object a “Trigger” and on the “OnTriggerExit” or “OnTriggerEnter” i make the “IsTrigger” false, but that wouldnt work because the character can jump on the object without touching it from below if he jumped at an angle.
I would really appreciate the help, and thanks in advance
Hi!
quick idea,
have each platform have two trigger colliders. one at the bottom of the platform and the other on top of the platform. when you hit from below, set a flag or send a message to temporarily turn the collider above it off.
thank you very much for the quick reply and your idea is very nice, but wont doubling the number of colliders sacrifice preformance? because i have alot of those objects
How about checking velocity direction. If it is up, then leave it as a trigger and if it is down then let it be a collider and move the character controller’s y position appropriately to be on the platform.
by too slow do you mean the trigger reacts too quickly and the character still hits the base of the platform? if so you could also add a WaitForSeconds (), but primes idea sounds more logical
i haven’t tested this yet but could you make single sided planes in a 3D app and import it as a collider? Hopefully, it would maintain it’s single sided normal and ignore whatever’s below that.
edit: guess that’s pretty much what Earl said but making it out of a 3D app would give you the ability to reduce the plane to two triangles.
Yes, that is what I was going to recommend. I am experiencing that with a plane I am using right now, and I was going to suggest that. Make a plane facing down, and it won’t collide with anything while you are moving up.
Hey, I understand that this is a very old thread, but this page is coming up on search engines that ask about one-sided collisions, and I found a solution that should help out anyone who finds this page through Google. So yeah, pardon the mega-bump, but this worked perfectly for me:
In your “Platform” script’s Update() function (C#):
if (GameObject.FindGameObjectWithTag (“Player”).transform.position.y < transform.position.y) {
GetComponent().enabled = false;
}
if (GameObject.FindGameObjectWithTag (“Player”).transform.position.y > transform.position.y) {
GetComponent().enabled = true;
}
Very simple and yet seems to work perfectly, at least in the case of my game. Just make sure you assign your player character with the tag “Player”.