Question by
abhishek7 · Feb 20, 2016 at 02:08 PM ·
buttonplatformersimple
How to allow player to move with platform (simple)
I've been trying for quite some time now to allow the player to move with the moving platform and essentially 'stay' on the platform while the player is able to control the player. So far I have been unable to do so/ Here's my code:
using UnityEngine;
using System.Collections;
public class PlayerPlatformMove : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "MovingPlatform")
{
transform.parent = other.transform;
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.tag == "MovingPlatform")
{
transform.parent = null;
}
}
}
I've been scouring the internet to find a suitable and simple solution, but I haven't found anything. Any help would be appreciated.
Comment
Your answer
Follow this Question
Related Questions
[Help] Event Trigger buttons not working? 1 Answer
Help! Create interactive button with an image + c# Script 0 Answers
Help with buttons 0 Answers
Change trigger for OnClick to a joystick button 0 Answers
Button to do two actions ?, 0 Answers