hello guys i need help
when i run my game from editor tile collider work but when i run it in my android device tilemap collider 2d is not working
Hello!
We will need more information for us to understand how is it not working for you.
Are you able to provide screenshots, code excerpts where it doesn’t work (if any, and use code blocks), or even videos to illustrate the problem?
EDIT:
I see you have created this new post after posting in an old thread, thanks for that!
Do post the additional information here so we have them in your own thread
Excellent. How to report your problem productively in the Unity3D forums:
This is the bare minimum of information to report:
- what you want
- what you tried
- what you expected to happen
- what actually happened, especially any errors you see
- links to documentation you used to cross-check your work (CRITICAL!!!)
If you post a relevant code snippet, ALWAYS USE CODE TAGS:
How to use code tags: https://discussions.unity.com/t/481379
If you have no idea what your code is doing, fix that first. Here is how:
You must find a way to get the information you need in order to reason about what the problem is.
What is often happening in these cases is one of the following:
- the code you think is executing is not actually executing at all
- the code is executing far EARLIER or LATER than you think
- the code is executing far LESS OFTEN than you think
- the code is executing far MORE OFTEN than you think
- the code is executing on another GameObject than you think it is
- you’re getting an error or warning and you haven’t noticed it in the console window
To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log()
statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
- is this code even running? which parts are running? how often does it run? what order does it run in?
- what are the values of the variables involved? Are they initialized? Are the values reasonable?
- are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)
Knowing this information will help you reason about the behavior you are seeing.
You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as Debug.Log("Problem!",this);
If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.
You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.
You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.
You could also just display various important quantities in UI Text elements to watch them change as you play the game.
If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: https://discussions.unity.com/t/700551 or this answer for Android: https://discussions.unity.com/t/699654
Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.
Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:
https://discussions.unity.com/t/839300/3
When in doubt, print it out!™
Duplicate post for ref: TILE MAP COLLIDER 2D NOT WORKING IN ANDROID BUILD
THANX FOR RESPONDING
THAT IS MY CODE FOR MY PLAYER
AS YOU SEE MY PLAYER HAVE RIGIDBODY2D AND I HAVE CREATE A COLLAPS COLIDER 2D FOR THE OBJECT.
IN INSPECTOR THE TILEMAPCOLLIDER2D IS WORKING BUT WHEN I BUILD AND RUN THE PROJECT ON ANDROID DEVICES TILEMAPECOLIDER 2D NOT WORKS;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class playerController : MonoBehaviour
{private Rigidbody2D rb;
private Transform tr;
public Joystick joystick;
public Button button;
private Animator anim;
public float Speed;
public float JumpF;
public float DjumpS;
public bool DjumpC;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatISground;
public bool isGrounded;
public playerController instance;
// Start is called before the first frame update
void Start()
{
rb=GetComponent<Rigidbody2D>();
tr=GetComponent<Transform>();
anim=GetComponent<Animator>();
joystick = FindObjectOfType < Joystick > ();
button = FindObjectOfType < Button > ();
button.onClick.AddListener(()=>Jump());
}
// Update is called once per frame
void FixedUpdate()
{isGrounded=Physics2D.OverlapCircle(groundCheck.position,checkRadius,whatISground);
if (isGrounded){ anim.SetBool("dj",false);}
var move=joystick.Horizontal;
transform.position+=new Vector3(move,rb.velocity.y,0)*Speed*Time.deltaTime;
if (move>0){transform.localScale=new Vector3 (0.06f,0.06f,0.06f);}
else if (move<0){transform.localScale=new Vector3 (-0.06f,0.06f,0.06f);}
anim.SetFloat("run",Mathf.Abs(move));
}
public void Jump(){instance=this;
if(isGrounded){
rb.velocity=new Vector3(rb.velocity.x,JumpF,0f);
DjumpC=true;
}
else if(!isGrounded&&DjumpC){
rb.velocity=new Vector3(rb.velocity.x,DjumpS,0f);
DjumpC=false;
anim.SetBool("dj",true);
}
}
private void OnCollisionEnter2D(Collision2D other){if(other.gameObject.tag=="movingplatform")transform.parent=other.transform;}
private void OnCollisionExit2D(Collision2D other){if(other.gameObject.tag=="movingplatform")transform.parent=null;}
}
My problem solved i have to turn on Generate Physics Shape thanx guys for help