#Never tried making one probably usefull
1 messages · Page 1 of 1 (latest)
oh,should i use this instead?
this
okii,sorry for the mistake
no worrys I never tried making one of these
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float xloc = Input.GetAxis("Horizontal");
float zloc = Input.GetAxis("Vertical");
float yloc = Input.GetAxis("Vehicleup");
rb.velocity = new Vector3(xloc * speed, yloc * speed, zloc * speed);
}```
they seem pretty usefull,especially in this situation
vehicleup is basically shift and controll for up/down
Oke so the problem was that he was going the wrong direction?
yea,if he were to rotate to face another direction
if he were to face towards the camera and i was to press on W then he'd move backwards
yea!
public float speed = 10f;
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
Vector3 targetVelocity = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), Input.GetAxis("Vehicleup") * speed);
rb.velocity = transform.TransformDirection(targetVelocity);
}
try this
transform.TransformDirection
rotates the direction vector based on the player transform
ooooh,that seems very usefull!
I think I do this in about every project
it works!!
i never thought of just putting the horizontal vertical and vehicleup in a vector3,thats actually pretty smart
Ye that keeps the code way cleaner, you also might want to use the new input system
Ye you can find it in the package manager, there is plenty tutorials about it
oh,could you send me a tutorial on it please?
✅ Get the FULL course here at 80% OFF!! 🌍 https://unitycodemonkey.com/courseultimateoverview.php
👍 Learn how to make BETTER games FASTER by using all the Unity Tools and Features at your disposal!
👇
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Gam...
very long video but when you know how to use it it's pretty easy
A no problem man, you can always ask my anything about Unity, I'm currently working a lot with Unreal and I get bored from that sometimes so I like helping people with Unity