I am just beginning to script (I have intermediate knowledge) and have never made a game. Just wondering if anyone was willing to help me to do so in unity with c#.
public float runSpeed = 5f; // controls player's speed
private float moveInput; // will tell the computer to move the player later on.
private Rigidbody2D rb; // this will be the rigidbody the forces will be applied to.
private void Start () {
rb = GetComponent<Rigidbody2D>(); // the game needs to know which object to apply forces to; it won't automatically know it's supposed to move the player
}
private void FixedUpdate()
{
moveInput = Input.GetAxis("Horizontal"); // Input.GetAxis("Horizontal") is a shortcut you can use in unity to use the arrow keys/ A&D keys to move forward
rb.velocity = new Vector2(moveInput * runSpeed, rb.velocity.y); // will cause the rigidbody to move depending on which buttons you press
}
/* This should get your character to move left and right, but not up/down. If you want them to move freely up and down, write :
moveInput = Input.GetAxis("Vertical"); right under moveInput = Input.GetAxis("Horizontal"); . Jumping is a little trickier.
since you need permission to use other people's work for this jam, I hereby declare that anyone participating in this gamejam can use this comment and it's contents to use in their games for whatever purpose. */
Do u have Discord. If so feel free to dm me so I can try to help. (@tipu#1178)I have been same situations like u In half year ago so I wanna really give my help. (but still im making my own game so be pacient when u ask something and be ready that I cant do everything. I just do Best as I can okay?)