Quantcast
Channel: Answers by "ThePersister"
Viewing all articles
Browse latest Browse all 99

Answer by ThePersister

$
0
0
Hey there @Rently, You mention the objects having the **Tag**; "**Platforms**", you're currently checking for the gameObject.**name** with "**Platform**". So first of all, try the following instead: if (col.gameObject.tag == "Platforms") { Aside from that, it's a good idea to check whether the OnCollisionEnter2D method is entered at all. Add a Debug.Log("Anything here"); before the if-stament. So try: void OnCollisionEnter2D( Collision2D col ) { Debug.Log( "Anything here" ); if( col.gameObject.tag == "Platforms" ) { rb.velocity = new Vector2( rb.velocity.x, jmpSpd * 0 ); isGrounded = true; Debug.Log( "isGrounded is true now!" ); } } If the debug is called and it still doesn't work, then the problem lies with the tag checking, maybe grammar spelling, or perhaps the tags haven't been set correctly or only on a single platform. Stuff like that. If the debug log doesn't get called, then you're probably doing something wrong with collision setups. To try and find issues, check this manual on Colliders here: https://docs.unity3d.com/Manual/CollidersOverview.html Which contains the very important collision matrix. ![Image of the Collision Matrix][1] Note that you're using the Collision method. This means you'll need at least 1 rigidbody involved, which is usually the player. The platforms **must** have either a rigidbody **OR** be marked static. ![Image of how to set an object to be static][2] Try and play around with that. I hope that helps! If this helped, please accept this answer, it'd be much appreciated! If you're still having trouble, let me know in comments below and I'll try to help! Best of luck! Cheers, ThePersister [1]: /storage/temp/83025-collision-matrix.png [2]: /storage/temp/83026-static.png

Viewing all articles
Browse latest Browse all 99

Trending Articles



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