Commit 39448712 authored by Michael But's avatar Michael But
Browse files

Objekt mit Slide Effekt

parent 6ca6e586
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SliderObject : MonoBehaviour
{
private Rigidbody2D rb;
public float force;
private void OnTriggerEnter2D(Collider2D collision)
{
if (!GetComponent<Rigidbody2D>())
{
rb = GetComponent<Rigidbody2D>();
}
else
{
Debug.Log("Kein Rigidbody");
}
if (collision.gameObject.CompareTag("Water"))
{
if(collision.transform.position.x > GetComponent<Transform>().position.x)
{
rb.AddForce(new Vector2(-force, 0));
}else if (collision.transform.position.x < GetComponent<Transform>().position.x)
{
rb.AddForce(new Vector2(force, 0));
}
}
}
}
fileFormatVersion: 2
guid: d5c135c3fe901cf4696abeebd2ac1f28
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment