- Home /
Imported model moves in the wrong direction
var speed : float = 0.3;
var acceleration : float = 1.0;
var deceleration : float = 0.3;
var brake : float = 0.4;
function Update () {
if(Input.GetKey(KeyCode.S)){
transform.Translate(Vector3(0, 0, speed));
speed = speed + (Time.deltaTime * acceleration);
}
if(Input.GetKey(KeyCode.Space)&&(0 < speed)){
speed = speed - brake * Time.deltaTime;
transform.Translate(Vector3(0, 0, speed - brake *Time.deltaTime));
}
else if(0 < speed){
speed = speed - deceleration * Time.deltaTime;
transform.Translate(Vector3(0, 0, speed - deceleration * Time.deltaTime));
}
}
When I use this script to a random block in Unity it works but when import a car model from Sketchup and try it, when I press the up key for it to go forwards, it goes up the Y axis! I'm pretty sure I aligned it correct in Sketchup so what's going on!?
Answer by Joyrider · Aug 14, 2013 at 12:38 PM
Be carefull, the objects' axes often change for imported objects, because of differences in axes and spacial logic between Unity and the modeling programs
In Sketchup, just like in 3DS Max, the up vector is the Z-axis.
Unity has the y-axis as the up vector and the Z axis as forward vector.
And Unity and Sketchup both use different Coordinate systems (LeftHanded vs. RightHanded) This causes axis to be different between your modeling program and Unity.
Yes! Rotate the model in $$anonymous$$odelling software so Z is forward and Y is up, then re-export.
Not sure that is going to solve it. The axes usually don't stay the same.
It happens to me with Blender. Z and Y are different so models always import on their backs
Answer by meat5000 · Aug 14, 2013 at 12:59 PM
In your Translate scripts try:
transform.Translate(Vector3(0, 0, speed, Space.World));
as an example. Space.World as suggested performs movement in world space. If left out it defaults to Space.Self, the local space.
If you never change direction cf. Rotate, than yes, you could try this. Otherwise, it'll get pretty complex.
You're better off setting an empty gameObject as parent of your imported model and put your scripts on there.
Your answer
Follow this Question
Related Questions
Are Imported SketchUp files bad for optimization? 1 Answer
Shooting an Arrow (Blender Model issue?) 1 Answer
Too many material elements on Blender imports? 2 Answers
Blender import issues. 2 Answers