i used
transform.Translate(Input.GetAxis(“Horizontal”) * 15f * Time.deltaTime, 0f, 0f);
When making my movment script, its a top down game and i need the player to move verticaly as well but i dont know how to apply this code verticaly. when i try it gives me errors or it doesnt work ingame.
how do i fix this
Show us your code and what the errors are.
1 Like
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WalkScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Input.GetAxis("Horizontal") * 15f * Time.deltaTime, 0f, 0f);
}
}
When i add
it stops working and doesnt move the character
transform.Translate(Input.GetAxis(“Vertical”) * 0f * Time.deltaTime, 15f, 0f);
i dont know how to format it corectly to get it to work
ok
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WalkScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//moves player horizontally
transform.Translate(Input.GetAxis("Horizontal") * 15f * Time.deltaTime, 0f, 0f);
//moves player vertically
transform.Translate(Input.GetAxis("Vertical") * 0f * Time.deltaTime, 15f, 0f);
}
}
when I add the vertical one it moves the player indefinitely upwards and I don’t know what’s wrong with it
Have a look at this post to learn how to format code for posting here in the forums.
In this line:
transform.Translate(Input.GetAxis("Vertical") * 0f * Time.deltaTime, 15f, 0f);
tell me what this part is doing:
0f * Time.deltaTime
creates a delay or speed?
wait im jst stupid and didnt realize i could do this
transform.Translate(Input.GetAxis(“Vertical”) * Vector3.up * 15f * Time.deltaTime);