Unity Who rummages, why I put speed.x then it goes like z although right now it costs y, but it goe

Someone, why put speed.x then it goes like z although right now it costs y, but it goes along the x axis?

Open Body Class: MonoBehaviour
{
public swimming speed = 5f;
private swimming = 0f;
new private rigid body Rigidbody2D;

// Start is called before the first frame update
void Start ()
{
Hardbody = GetComponent ();
}

// Update is called once per frame
void Update ()
{
motion = Input.GetAxis (“Horizontal”);
hardbody.velocity = new Vector2 (movement speed *, solidbody.velocity.y);
}
}
coming down to earth

I don’t understand this question… at all.

1 Like

why we use rigidbody.velocity.y instead rigidbody.velocity.x for run?

you understand my question?

When you set velocity.y, you set the speed of the object along the y-axis. Same goes for x and z-axis.

This might be the least comprehensible post I’ve seen on these forums.

1 Like

Rummages? Who?

Likely not, since they just stated otherwise.

And this code would not compile, there is no movement variable, and * at the end of the first param is incorrect syntax.

hardbody.velocity = new Vector2 (movement speed *, solidbody.velocity.y);

I’m guessing the poster ran all the code through a translator instead of just his/her question. Unless the float type has actually been renamed to “swimming” officially. Hardbody is probably supposed to be Rigidbody, etc.

2 Likes

That makes this post make a LOT more sense.

I bad understand English, but now i write without translate i just russian, my qustion such.
Why we use rigidbody.velocity = new Vector2(movement * speed, rigidbody.velocity.y instead igidbody.velocity = new Vector2(movement * speed, rigidbody.velocity.x so that run

I bad understand English, but now i write without translate i just russian, my qustion such.
Why we use rigidbody.velocity = new Vector2(movement * speed, rigidbody.velocity.y instead igidbody.velocity = new Vector2(movement * speed, rigidbody.velocity.x so that run

1 Like

strange, when i put rigidbody.velocity.y then he go on x-axis

sorry for mistakes my English is very bad , i just russian

1 Like

In general, the best is to use physics properties of rigidbody, to apply force (or timed translate or rotate) a game object that rigidbody is attached to, for such purposes. Does your object have any other (sub) parts in the prefab with the scripts on it, that cause you this effect ? so … check that first, and if you don’t mind sharing a secret (that particular script here) people on the forum like to help and can definitely write you some better version of it, so you can use it later to learn more, improve on it as well and what not. P.S. Putin has a lot more of better photos, update it before you get shipped to Siberia (just a joke) :).

is your object oriented so that y is up and x is pointing to right? is your object’s rotation (0,0,0)?

1 Like

and what you say
about Siberia, i’m live beside with Siberia
there not fun

yes

Да кстати, я код через переводчик пропустил, не спрашивай зачем, сори что приходится переводить мои слова=)

As some people don’t get it, It’s just a joke, for living next to Siberia you will definitely have a good sense of humor - anyways, keep us updated on the problem if we can help further, it sounds that it need to be checked if there is an issue of game object being rotated by the game object, instead of by rigid body, or if there are sub objects in the prefab doing that wrong effect, so you need to check that first, before any further code excavations. Your code concept is not bad, but be careful declaring stuff in #C, and than if properly declared - go using the declarations further down the script and what not, as you know - all the wrong things in #C - start in the header declarations (despare ye not - if you have done this in JS - it will be 10 times worse to fix) :).

We don’t use Y axis for velocity for runs (translations forward-back), unless you want the object to take off (up vertically), for translation forward-back is the best to use Z axis, which is horizontal one in Unity. So … assumedly Y is vertical axis - anything with Y axis used (with any ± value of more than zero in it), will give you the jumps or falls down, so simply avoid any numbers higher than zero for any axis in your game object that is pointed up, if you want translations forward-back, eg, walk, run, drive, etc, you work with Z and X axes numbers for that (assumedly they are horizontal ones), hope it helps :).

1 Like

I have a 2D game, and when I want my character to go I need to do velocity.y to jump velocity.x, I just don’t understand why it is so? I watched the review, the boy also had it, and it’s kind of normal