Does anyone have a script that would allow me to change cameras? If not, could someone point me to a tutorial or something? Thanks. Now for the real question: I have a game where you are flying in a spaceship and when you fly too close to a planet it loads a level (namely the planet level). I used the AND operator for this:
First off, use more parenthesis. This is fairly unreadable.
And secondly, I think it’s saying that is not something that can be used with variables, alongside math functions.
This is absolutely not what your script is doing.
You’re checking to see if…
z is greater than 6088…
z is less than -5826
x is greater than …
I think you have your initial .z test wrong.
Parenthesis and whitespace would have solved this for you, visually. You didn’t save anything by trying to do it on one line, but you did confuse the heck out of yourself
I’m not quite sure what you mean by this, and I can’t think of an interpretation that makes sense. Can you clarify? (Also, although the use of parentheses in your example looks to be technically correct, it doesn’t improve the readability, IMO. For one thing, the parenthetical groupings don’t follow a logical pattern, which negates their usefulness somewhat.)
In any case, the question has already been answered here.
I’ll try to answere this, I think Bounds.Contains is a short way of doing what you did with you’re script where you checked every axis on after the other , But remember that Bounds is a struct which is short for structure
an example of how to use the Bounds struct:
Bounds(Vector3.zero,Vector3(1,1,1)).Contains(Vector3(0,1,0))
center size dot you want to check if it contains
Right, I was following what I thought at the time was your logic. I see now that you did not intend to have that parenthesis there. When I was regrouping them, I added an additional one to make the compiler happy.
Again, the error in your code, which is preventing it from building is the parenthesis.
The error in your logic is the way you’re checking the first variable. That’s why it’s still not working for you.
Otherwise, that is perfectly valid logic, which will (and does) work.
This does the same thing as a ‘contains’ function call, only with more code.
Thank you everyone. You were all very helpful. The problem wasn’t with the script so much as it was was me. I made things way over complicated… As we all sometimes do…
To give the desired effect, I created an empty object, add a huge sphere collider, tagged it “earth” and added this code to my spaceship: