
The niave solution would simply be to referance the gun's transform and use that to determine the bullets direction. It seems you actually would want to do this for the gun. Right now you are moving the bullet to the left/right when the mouse is on the left/right of the bullet. It looks like you have confused what you are looking at for the "direction"
UPDATE TRANSFORM.X UNITY VECTOR 2D UPDATE
These scripts are in the update function. Transform.Translate(-transform.right * projectileSpeed * ltaTime) Transform.Translate(transform.right * projectileSpeed * ltaTime) This is the script in the weapon that spawns the projectiles. it made my projectile shoot towards left and right, but the projectile is still changing the direction after the spawn, depending on the mouse position. I realized the projectile was only going to the right, so i figured out I should use a -transform.right in order to make my projectile go to the left when my mouse is on the left.īut it didn't went as I expected. Given distinct points P 0 and P 1, a linear Bézier curve is simply a straight line between those two points.So, I was making my projectile move in my 2d game. The sums in the following sections are to be understood as affine combinations – that is, the coefficients sum to 1. The first and last control points are always the endpoints of the curve however, the intermediate control points (if any) generally do not lie on the curve. Yet, de Casteljau's method was patented in France but not published until the 1980s while the Bézier polynomials were widely publicised in the 1960s by the French engineer Pierre Bézier, who discovered them independently and used them to design automobile bodies at Renault.Ī Bézier curve is defined by a set of control points P 0 through P n, where n is called the order of the curve ( n = 1 for linear, 2 for quadratic, 3 for cubic, etc.). The mathematical basis for Bézier curves-the Bernstein polynomials-was established in 1912, but the polynomials were not applied to graphics until some 50 years later when mathematician Paul de Casteljau in 1959 developed de Casteljau's algorithm, a numerically stable method for evaluating the curves, and became the first to apply them to computer-aided design at French automaker Citroën.

Bézier curve is named after French engineer Pierre Bézier, who used it in the 1960s for designing curves for the bodywork of Renault cars.

-unity.png)
Usually the curve is intended to approximate a real-world shape that otherwise has no mathematical representation or whose representation is unknown or too complicated. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. eɪ/ BEH-zee-ay) is a parametric curve used in computer graphics and related fields.

The basis functions on the range t in for cubic Bézier curves: blue: y = (1 − t) 3, green: y = 3(1 − t) 2 t, red: y = 3(1 − t) t 2, and cyan: y = t 3.Ī Bézier curve ( / ˈ b ɛ z.
