#Issues with code in my build that only show up in the build, but not in the editor.

1 messages Β· Page 1 of 1 (latest)

warm delta
#

file for code for rotation methods and stuff

warm delta
#

Bump

tawny pulsar
#

Code pls

warm delta
tawny pulsar
#

Does it break in the editor after removing all debug related code? like Debug.DrawLine and such

warm delta
#

why would it break in the editor after removing the debug code?

tawny pulsar
#

I wonder why it would break in a build at all

#

All I can think is somehow, some code only runs in an editor, and it can be anything

#

And you have these debug parts, and who knows they somehow change behaviour

#

I really doubt it though

warm delta
tawny pulsar
#

Yes, the jittering

warm delta
#

with like the frame where it jitters slightly

#

let me remove the debug stuff real quic

crystal flare
#

Highly doubt it's the debugs. I thought maybe the sprite was getting loaded in dynamically. Sprite comes in at its prefab's rotation, take a little longer in build (compared to editor) to load, and voila you see it in the wrong orientation for a frame. But not doing that either.

#

Can you send project @warm delta? Thinking there might be something in the animator.

warm delta
#

is a zip file good?

#

ill dm cus i dont wanna put it here

crystal flare
#

ugh I was able to reproduce the error in editor. and then I fixed it in the editor, but I still see a little messed up frame in the player and I dont see a logical reason why. But I think its a little better? I'm curious how it would look on your end.

#

Twofold problem:

  1. You need to use Update for the sprite flipping. FixedUpdate runs 50 times a second, so if your game runs higher >50fps, then youre going to see frames where the flip is lagging.
  2. You need to make sure that your PlayerManager Flip and your PlayerArm flip agree on the right threshold to flip. If the player flips before the arm, the change in the localScale is going to cause the arm to be pointed down until it flips as well.
#

Here's PlayerManager:

difference = _camera.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x;
transform.localScale = new Vector3(Mathf.Sign(difference)*size, size, size);  

and PlayerArm:

difference = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - transform.parent.position.x;
transform.localScale = new Vector3(Mathf.Sign(difference), Mathf.Sign(difference), 1f);
#

I changed difference to a float to simplify the problem on my end, but should translate easily back to Vector3 if you need to continue to use.

crystal flare
#

Hmm just tried setting and caching the mousePosition in OnGUI. Not sure why yet, but combined with the above instructions, the error disappeared for me in build.

#
Vector3 mousePosition;

void OnGUI(){
  mousePosition=Input.mousePosition;
}

void Rotation(){
  ...
  ...Camera.main.ScreenToWorldPoint(mousePosition).x...
  ...
}
#

OnGUI could run several times per frame, so maybe that's the difference. Either way, hope this all helps.

warm delta
#

and thanks for taking the time to do this

crystal flare
#

OnGUI is just another Unity message like Start or Update. It is where IMGUI would be rendered if you were using that.

warm delta
crystal flare
#

caching your mouse position isnt expensive

warm delta
crystal flare
#

I locked the angle to 90 and moved my mouse back and forth quickly. Also moved switchCutoff to one side.

warm delta
#

whats the camera.main.screentoworldpoint.x for? just the x component?

#

oh wait

#

sorry im just reading the whole thing now

crystal flare
#

The ellipses just mean "there is other code here that I didnt write"

warm delta
#

should i use .magnitude to get the float value?

#

because right now diffference is a vector3

crystal flare
#

right, so you can either change the type of difference to float or subtract the Vector3s instead. I personally would just make difference a float.

warm delta
#

ohhhhh

#

okay i see

#

all the angle stuff is fine though right?

crystal flare
#

yes, as far as I could tell

warm delta
#

@crystal flare dude thank you so much, applying your fixes has fixed the issue completely.! I can finally focus on other things for my game, because that was really pissing me off lmao

#

i really appreciate the time you took out of your day to fix my issue πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„πŸ˜„

crystal flare
#

No worries. Glad I could help. To be clear, I think there is probably still some underlying issue, like some kind of race condition between parent-child scaling. But I'm happy it's working better for you.