Question by
fredigavanjero22 · May 29, 2020 at 08:33 PM ·
scripting problemobjectbug
Script doesnt work properly on 1 object
Im making Icy Tower clone . I made that platforms go down and when they exit the screen they will reapear at the top resized . When i get close to top falling speeds up just enought for it to get me down past certain point. When i get to speeding up point only 1 platform out of 7 doesnt move like it should be. All 7 platforms have the same script and the same components but only that 1 doesnt work.
Here is my code
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Fallingmechanism : MonoBehaviour { [SerializeField] float falling_speed;
Vector2 falling;
Vector2 speed_up_falling;
float speed_up_border;
[SerializeField]
GameObject Player;
[SerializeField]
GameObject border_point;
void Start()
{
falling = new Vector2(0, falling_speed);
speed_up_border = border_point.transform.position.y;
}
void Update()
{
transform.Translate(falling * Time.deltaTime);
if(Player.transform.position.y>speed_up_border)
{
speed_up_falling = new Vector2(0, Player.GetComponent<Rigidbody2D>().velocity.y * (-1f));
transform.Translate(speed_up_falling * Time.deltaTime);
}
}
}
sry for any mistakes in English
Comment