Rotations screwed up on build

I’m making a game where a player is behind a turret on a truck, things are really coming together in the editor, but when I try to export to a windows .exe or a web build, a lot of my axes just mess up or switch.

For example I have it set to where mouse movement on the X axis rotates the turret about its Y axis (upward) so that it turn to the left and right. And mouse movement on the Y axis rotates the turret up and down.

Also the barrel of the turret spins about on its local Z axis (it is pointed outward in the Z direction)

When I go into build however, the up and down turret movement work fine, but the X axis movement goes from moving the turret left and right to swiveling around the Z axis.

Also the barrel now swivels around the Y axis, looking bugged as all getup.

I am using custom .fbx from Max, I had a hell of a time getting the right rotation, but I think that part is all ironed out.

I cant for the life of me figure out why I’m having this problem though. Any thoughts?

small bump…

no one has had a similar problem? this is fairly game breaking for me…

Does it work when you play it in the Unity Editor?

I have not encountered this issue and almost all of my builds are windows or web. :stuck_out_tongue:

Yes it works perfectly in the editor its just when switching to builds when things start messing up. I want to nip this in the bud before I get too far along with my game and find out there’s a fundamental problem with it etc…

Here’s an example of code I attached to the barrel

function Update() {

if (Input.GetButton ("Fire1"))
{


transform.Rotate(0, 0, 10 );

}
}

In the editor this rotates the barrel about its Z axis (making it spin like a barrel would)

However on exporting to game it rotates about the Y axis. Here’s the weird thing. If I set all values to 0,0,0 it STILL rotates about the Y axis. So I started thinking, maybe its not this script that’s affecting it - but when I disable the script the barrel stops spinning all together (i.e. the script is causing it).

This isnt the only problem, but its a very simple script and it’s demonstrating one of the big problems I’m having. If I figure this part out maybe it will shed some light on the other problems.

Well, without looking over the whole project I cannot really help you. :stuck_out_tongue:

I’ve now commented the entire code out for the barrel spin, and it still does it. However if I disable the script it doesnt move. So something in an entirely commented script is causing it to move this way?

I would be happy to zip up the project and send it to you if you could take a look at it.

edit is it possible my project file is just corrupted?

I tried a very simple spinning cube test (press jump to rotate the cube) and it wouldnt work in game with that project. I created a new project and imported the script. It worked fine.

At any rate im going to import my turret setup in a new project and see if that helps.

Yes. We had this on the Uni computers. If you run Unity over a network or off a keydrive even once it can corrupt the library so that changes no longer get submitted correctly and all sorts of odd things happen.
I had a script with an error in it once, I tried everything even deleting the script from my assests folder. But the compile error continued.

To solve it we, close Unity, deleted the project Library folder and then re-opened Unity.
Seemed to work fine then.

There may be other cases where similar corruotion can occur.

One warning, doing this with the Library will mean that a lot, if not all, of your prefabs will break and all of your script Objects will revert to default.

Whew…ok well the new project works fine. It must be corrupted. I’ve only ever run Unity over my own computer on the HDD. I wonder if a Proxy might cause it to happen? That’s the only thing I can think of network related. I’m in China so I’m constantly switching my proxy on and off - but that would be for outgoing, not internal - oh well maybe just bad luck.

Anyways about the prefabs breaking etc. What I did was export my prefab as a unitypackage. I’m not sure if this is the most efficient way to do it but it ports my stuff over without problems, all the scripts etc intact.

Thanks for your help. I’m kind of a n00b to scripting, so I can handle it when I make a mistake and it doesnt work, but having literally no cause/effect in my programming was starting to get VERY frustrating :slight_smile:

Oh also, while I’m kind of on the topic. I’m curious my build works now, both windows and Web. But my windows exe seems to stutter quite a lot, doesnt update my muzzle flash consistently (same one from the FPS tutorial). It just acts like it’s under a lot of stress. However the web build works perfectly.

Have you run into this as well?

Alright I just made some changes to the script, back and forth between slow and fast barrel speeds. But now the builds are not reflecting the editor again. (The editor is working correctly but the builds are not updating sometimes) This is a completely new project, so I think that means a new library right?

Does this mean the Unity install is actually corrupted somehow?

If just changing scripts and moving things around in a scene will corrupt the build I don’t exactly know how I can work on a project. Things seem to work if I import a package from another project and run it, but making changes seems to mess it up again…frustrating

I cannot see how the Unity install should effect that.
Something you are doing is messing it up.
A proxy shouldn’t be the problem.

I am afraid someone with more know-how about Unity will have to help you there. :frowning:

I have not run into any of the other problems you mentioned there. Sorry I cannot help you any further.
If you don’t mind sharing your project and I can see if it runs fine on my comp I could do that. At least we would know if it is your install or anything else.
Else just wait until a Unity rep sees this and can respond.

Something to check… are you getting error messages for the project? Check the console window rather than just the bottom status bar to be sure. Sometimes, an error somewhere will stop the script from compiling and the changes you believe you’ve made will not show up.

Well I’m new to this whole software but if it works in the editor, doesn’t that mean the scripts have compiled already?

I remember seeing some errors but I think there were associated with particles which stopped after I removed them…If I see anymore I’ll be sure to post them.

If you play the project while there are errors in the code, Unity uses the last successfully compiled version of the code. It is quite easy to change a piece of code, run it and be surprised to see no result, only to eventually realise that the changes were not applied because of an error somewhere else in the file. A particular problem is that the bottom status bar only shows one error. The error shown here might not be in the file that is causing the problem, so you need to check the console window to be sure.

Right I understand that. I think there’s a bit of a miscommunication here.

I’ve run into the situation where the code doesnt compile and the editor uses the last good version. (And I do check to see the whole console) When this happens I figure out the error and fix it, and the editor works fine.

The major issue I am having is that when I change the script and the editor accepts it (meaning it updates because the code is valid) - but on compiling to build it doesnt reflect some changes I have made, also sometimes changing random things like rotation axes of objects.

I’ll be testing it on another system tomorrow and if it doenst happen there I’ll just chalk it up to a bad install or something. I really cant see any rhyme or reason for it.