#smthin does not happen
1 messages · Page 1 of 1 (latest)
So where do you want to call the function?
when i exit the platform (the white thing (im the blue block))
and i use : void OnCollisionExit2D(Collision2D coll)
- mixing canvas ui with physics(colliders) is a very bad idea.
Remake your scene with sprite renderers or avoid using collisions.
ok so i just delete the component box collider on everithin and replace with sprite render?
Not box collider. Remove rect transforms(replace with regular transforms), remove Image components and add Sprite renderer. Box colliders are fine on sprite renderers.
ok
It's easier to just scrap that whole canvas and create everything from scratch
btw what scale is for 1920 and 1080 (x and y)
ok somehow did it
and i cant see the player cuz the platform is overlaying him
Play with the sorting order
the platform shall be sorting layer 1 or 2
try it out and see which one works
btw can i do it throught z? cuz it works best
No. That's gonna mess stuff up. In 2d you should strictly use sorting order
and make sure everything has the same Z pos.
Why is it parented to the canvas?
ooh
i made the player platform and enemy with sprite render transform and box collider 2D
but when i click play i just zooooooom to the blue space
next to the platform
Pause your game during play. Switch to scene view and 3d mode and look around. Where are your objects/camera positioned relative to each other?
Take a screenshot of the scene so that all the objects and camera gizmos are visible.
Seems to be fine according to the camera preview
What happens? I don't understand what the problem is from that video.
the cube just go away from the platform
and i want to make the cube be on the platform and detect when i left the platform
Share screenshots of player and platform inspectors
At least one of the colliding objects needs a rigidbody for physics events to get fired.
the player have rigid body
in my perspective of the screenshot it was there
but still how do i fix
heeey
It could also be because the objects start as already colliding, so on exit is not called.
Share your code again
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovment : MonoBehaviour
{
private Input input;
private Rigidbody2D rb;
public Vector2 input_Movment;
public float moveSpeed = 10f;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
input = new Input();
InputEnable();
}
private void InputEnable()
{
input.Enable();
}
private void InputDisable()
{
input.Disable();
}
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.name == "Enemy")
{
Debug.Log("coll");
return;
}
}
void OnCollisionExit2D(Collision2D coll)
{
if (coll.gameObject.name == "Platform")
{
Debug.Log("haha U gay");
return;
}
}
private void FixedUpdate()
{
Vector2 moveInput = input.Character.Move.ReadValue<Vector2>();
rb.velocity = moveInput * moveSpeed;
}
}
its bcz the platform have box colider cuz without it it works normaly but i cant detect the collisions without collider
Comment out input.Disable();
Because that's the only reason I can think of why your character floats up without you doing anything
cant it be cuz im in the block that have box collider so the block makes me go out of him?
bcz without box collider on the platform it works fine
Ah, yeah. It could. It just seemed too slow on the video...
If you want to disable physical collisions between the platform and the character, mark it as a trigger.
Did you change it to OnTriggerExit?
ooh
what shall i change collider2D to?
void OnTriggerExit2D(Collider2D coll)
cuz i tried Trigger2D but error
thx