Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Why is my gameObject falling so slow?

$
0
0
I was testing out my own pathfinding script, and it worked, but only on the x axis, whenever the enemy falls, he falls super slowly, while all the other objects fall normally, could someone tell my why? I gravity turned on in the rigidbody menu, and it's the same speed as everything else, so i don't know why it does this. Here's my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class SlimePathfinding : MonoBehaviour { public float speed = 5f; public Transform target; public Rigidbody2D rb; void Start() { rb = GetComponent(); } void Update() { Vector2 currentPos = transform.position; Vector3 Scaler = transform.localScale; if (target.position.x > currentPos.x) { Scaler.x = -1; transform.localScale = Scaler; rb.velocity = transform.right * speed; } else { Scaler.x = 1; transform.localScale = Scaler; rb.velocity = transform.right * -1 * speed; } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>