Timeline for Moving left and right not working as expected
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 14, 2016 at 20:04 | comment | added | McArthur Alford | For me unity decided that i have to do the boxcast twice. I realise i shouldnt have to do it twice in the if statements but unity seems to force me to. I get invalid object errors if i dont. | |
| Aug 14, 2016 at 19:59 | vote | accept | McArthur Alford | ||
| Aug 14, 2016 at 4:43 | comment | added | Gnemlock | I think I have found the problem. That said, why are you storing a RayCast2D by performing a Physics2D.BoxCast(), before immediately performing the same Physics2D.BoxCast() to check the resulting RayCast2D for an if statement? You literally just stored the value. Why don't you just check the RayCast2D variable, instead of performing the same Physics2D.BoxCast() again? You do this quite a bit (as well as similar instances where you could benefit from storing new Vector2 once instead of calling it twice), which would have some sort of impact on your overall performance. | |
| Aug 14, 2016 at 4:38 | answer | added | Gnemlock | timeline score: 0 | |
| S Aug 14, 2016 at 0:53 | history | suggested | Gnemlock | CC BY-SA 3.0 | converted title into single sentence, fixed punctuation and sentence structure, applied correct code format and removed redundant code, including commented out variables and default functions without any code |
| Aug 14, 2016 at 0:09 | comment | added | Gnemlock | Also, you say the left script and right script are exactly the same. In this one script, I can see you handling both left and right. Is there another script? Or do you mean to say you handle the logic the same, as they are handled in the same script? | |
| Aug 14, 2016 at 0:07 | comment | added | Gnemlock | I've tried to clean up your code sample as best as I could (no reason to include empty functions, and commented out variables are not being used). Generally, you want to make your code as minimalist as possible to replicate the same problem you describe. I will try to figure out what is happening, but first I'm going to have to clean up your code a bit more. | |
| Aug 14, 2016 at 0:05 | review | Suggested edits | |||
| S Aug 14, 2016 at 0:53 | |||||
| Aug 13, 2016 at 23:54 | review | First posts | |||
| Aug 14, 2016 at 0:09 | |||||
| Aug 13, 2016 at 23:51 | history | asked | McArthur Alford | CC BY-SA 3.0 |