#mystupidcode
1 messages · Page 1 of 1 (latest)
Well for axis inputs it's fine. But if you forget and put a button press in there it won't work most of the time.
oh ok
good point! forgot axis is good
ok now to my question
.
how do i do that
just give me an example
float yRotation = OBJECTA.transform.eulerAngles.y;
OBJECTB.transform.eulerAngles = new Vector3(OBJECTB.transform.eulerAngles.x, yRotation, OBJECTB.transform.eulerAngles.z );```
let that be a lesson not to just copy and paste things, i sent that as an example to look at and see what its doing.
ok i will try to figure it out
show what you did with it anyway
wait a sec
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class wheelmovement : MonoBehaviour
{
public void Update()
{
GetInput();
}
public void GetInput()
{
m_horizontalInput = Input.GetAxis("Horizontal");
m_verticalInput = Input.GetAxis("Vertical");
}
private void Steer()
{
m_steeringAngle = maxSteerAngle * m_horizontalInput;
frontDriverW.steerAngle = m_steeringAngle;
float yRotation = m_steeringAngle.transform.eulerAngles.y;
Steering.transform.eulerAngles = new Vector3(Steering.transform.eulerAngles.x, yRotation, Steering.transform.eulerAngles.z );
}
private void accelerate()
{
rearDriverW.motorTorque = m_verticalInput * motorForce;
}
private void UpdateWheelPoses()
{
UpdateWheelPose(frontDriverW, frontDriverT);
UpdateWheelPose(rearDriverW, rearDriverT);
}
private void UpdateWheelPose(WheelCollider _collider, Transform _transform)
{
Vector3 _pos = _transform.position;
Quaternion _quat = _transform.rotation;
_collider.GetWorldPose(out _pos, out _quat);
_transform.position = _pos;
_transform.rotation = _quat;
}
private void FixedUpdate()
{
GetInput();
Steer();
accelerate();
UpdateWheelPoses();
}
private float m_horizontalInput;
private float m_verticalInput;
private float m_steeringAngle;
public WheelCollider frontDriverW;
public WheelCollider rearDriverW;
public Transform frontDriverT;
public Transform rearDriverT;
public float maxSteerAngle = 30;
public float motorForce = 50;
public Transform Steering;
}
@timber kindle
ur passing in the floats rather than the gameobejcts transform
m_steeringAngle is not a gameobject, how can it get its transform ?
well i need it to be float
that's why said not to copy without understanding what it does.
you asked how to set obja to rotation Y of objb
if u got m_steeringAngle already
would that work
yes
it would prob then be cs Steering.transform.eulerAngles = new Vector3(Steering.transform.eulerAngles.x, m_steeringAngle, Steering.transform.eulerAngles.z ); ?
np. glad its working
now i just need to limit rotation of baars same way i did with wheels
i cant believe its almost finished
yes just a simple clamp
this is really stupid question but
this is my first time using clamp so
i will just watch a tutorial
i guess
close but you don't need +0
the first arguement is just the variable
no floats
also -0? lol wut
idk what to do
now
@timber kindle
figured it out
i dont need clamp
i have another problem
@timber kindle
hey so the code didnt work out
so i found anoother solution
i just made bars clild to front wheel
but now it rotates with wheels in x axis
wdym the code "ddint work out"
i tried limitimg rotation but
code worked until oi started driving
i will show u vid
Here
@timber kindle
the wheel turns ok?
Yes it didn't have any problem before too
just parent handle bars to wheels, looks like ur rotating both, differently
lol
I know
maybe constraints
doesnt do anything
damn
maybe i should write simple code that will keep rotation 0
i tried that but i did some stuff wrot
wrong
so maybe u know
where the new code that moved the handlebar