T
T
timtimtimtimtimtim2022-01-28 17:25:11
Unity
timtimtimtimtimtim, 2022-01-28 17:25:11

How to make the character move and jump like in google chrome dinosaur river?

How to make a character move and jump like in google chrome dinosaurrek

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
timtimtimtimtim, 2022-01-28
@timtimtimtimtim

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class your script name : MonoBehaviour
{
public float speed;
public float jumpForce;
protected bool doJump = false;
public Rigidbody2D rb;
// Start is called before the first frame update
void FixedUpdate()
{
if(doJump)
{
rb.AddForce(Vector3.up * jumpspeed, ForceMode2D.Impulse);
dojump=false;
}
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.right * speed);
if(Input.GetKeyDown("space"))
{
doJump = true;
}
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question