- Home /
Question by
Chrisballas69 · May 26, 2020 at 04:12 PM ·
unity 5unity 2d2d-platformernewbienew
Need my character to move with platform,I need to make it so when i touch anything with the tag mov platform my character moves with it
I want my character to move with anything that has the tag "Mov Platform" but i dont exactly know how i used smth from a tutorial online but didnt seem to work the rest of my OnCollisionEnter script works tho
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Touching : MonoBehaviour {
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "Enemy") {
SceneManager.LoadScene ("Tutorial Level");
if (col.gameObject.tag == "Mov Platform")
this.transform.parent = col.transform;
}
}
void OnCollisionExit2D(Collision2D col)
{
if (col.gameObject.tag == "Mov Platform")
this.transform.parent = null;
}
}
Comment
Your answer
Follow this Question
Related Questions
How do i change the sprite on a sprite renderer without changing the size? 1 Answer
What are the best practices when importing 2D pixel sprites 1 Answer
Unable to click/touch event on sprite 1 Answer
How can I publish my game 64bit and 32 bit on google play 2019? 1 Answer
Getting error when I am trying to build this game on my android device. 0 Answers