Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [CreateAssetMenu(fileName = "Ability", menuName = "Ability", order = 1)]
- public class Ability : ScriptableObject {
- [SerializeField] private float vitesseHorizontal = 0.0f;
- [SerializeField] private float vitesseVertical = 0.0f;
- private int directionHorizontal = 1;
- private int directionVertical = 1;
- public void Bouger(Transform ballTransform)
- {
- Vector3 ballPosition = new Vector3();
- ballPosition = ballTransform.position;
- ballPosition.x += (vitesseHorizontal * directionHorizontal);
- if (ballPosition.x > 5)
- {
- directionHorizontal *= -1;
- ballPosition.x = 5.0f;
- }
- else if(ballPosition.x < -5)
- {
- directionHorizontal *= -1;
- ballPosition.x = -5.0f;
- }
- ballPosition.y += (vitesseVertical * directionVertical);
- if (ballPosition.y > 5)
- {
- directionVertical *= -1;
- ballPosition.y = 5.0f;
- }
- else if (ballPosition.y < -5)
- {
- directionVertical *= -1;
- ballPosition.y = -5.0f;
- }
- ballTransform.position = ballPosition;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement