i use getcomponent().velocity = new vector2( transform.right,rigidbody2d>().velocity.y) but i get an error about invalid arguments with floats
Because transform.right
returns a Vector3
not a float
.
Use instead transform.right.x
A suggestion to optimize will be caching the components rigidbody and transform {if u are doing it on every frame}.