Question by
jimmey_gamal · Apr 18, 2017 at 07:03 AM ·
c#transformposition
i need to change box position in y axis if i hit from down (c# script) 2d
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class destroyblock : MonoBehaviour {
// Use this for initialization
void Start () {
float y= gameObject.transform.position.y;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other)
{
transform.GetComponent<Collider2D>().isTrigger=false;
if (other.tag=="player")
{
transform.position.y += 1;
}
}
}
Comment
Answer by Lapius · Apr 18, 2017 at 12:25 PM
I think easiest way is to check if players velocity is upwards.
Or just use unitys platform colliders just to opposite side.