So I want my player to fall and collide with an object thats still. I want my player to fly back up and fall down after collision and i want the object to start moving left and right at different speeds each time they collide. I got my object to float left and right I just dont know how to get it to change speeds and push the player back up. Any wise sage would be appreciated. My code so far
using UnityEngine;
using System.Collections;
public class Floater : MonoBehaviour {
public float floatSpeed = 2.0f;
public float wallLeft = 0.0f;
public float wallRight = 5.0f;
float floatingDirection = 1.0f;
Vector3 floatAmount;
// Update is called once per frame
void Update () {
floatAmount.x = floatingDirection * floatSpeed * Time.deltaTime;
if (floatingDirection > 0.0f transform.position.x >= wallRight)
floatingDirection = -1.0f;
else if (floatingDirection < 0.0f transform.position.x <= wallLeft)
floatingDirection = 1.0f;
transform.Translate(floatAmount);
}
}
: