When you shoot, how do you detect whether you hit?
I'd suggest performing the same kind of check (would guess some ray cast) and just use that.
If going that route, you could also cache the result, so you don't have to do another check when firing, but that might depend on your weapon (e.g. if you have a weapon with a high amount of spread, your crosshair might be red, even though bullets might miss).
got the previous crash without ~Ausfaelle(); but with that I get undefined symbol and no crash. My app doesn't even load. undefined symbol: _ZN9AusfaelleD1Ev
~Ausfaelle(); is the declaration of a class destructor.
If you've declared it, you also need to define it (in the .cpp, like you do with the other normal class functions).
I would also suggest you use a debugger and step through, and see where the application crashes.
EDIT: That said, I don't see your class as needing a custom destructor. If you do not provide one, a default destructor is generated for you. You need a custom destructor in certain cases*, but I don't think your case requires one. I think something else is going on. Stepping through with a debugger seems like the best bet.
I think this is because your std::vector is defined and lives at global scope. It gets destroyed when the application exits (at the end of/after main returns), but you check for memory leaks while the application is still running (inside main).
EDIT: I think I might have misunderstood this completely. Ignore the following
Usually, when this axis rotation function is invoked, it is called 3 times, once for each of the bases vectors x, y, z; The faster of the two implementation (2nd one) involves me defining float variables and calculating the sine and cosine values once in my my caller routine before invoking this function. However, this clutters my code more than I care for, as I would like my code to be more legible. With the solower implementation ( the first one), my code is less cluttered, and I don't have to track additional variables, but I am having to invoke the math function cosf() and sinf() 3 more times than normal, in mose cases:
I move the object to a position I want it. When I use Unity to play the game it moves my object to a different starting position than the one I positioned the object. LOL. I have no clue why its repositioning it.
I hope someone can help me out. I'm going to experiment with the code you gave me up above.
It changes position because Mathf.PingPong returns a value from 0 to length (length in your case being 10).
I can't remember the exact syntax and I don't have Unity in front on me, but you could try...
- Create a new Transform variable (not public), startPos.
- On Awake or Start, set startPos to the current position. This should grab the position you set in the editor, and store it in startPos.
- On Update, do startPos.x + Mathf.PingPong() instead of just Mathf.PingPong(). This will take the start position, and then add in the PingPong motion on top of that.
arctan parameter order is usually (y, x) -- not (x, y).
Apart from that, I'd suggest just printing out some debug values as you spin the camera to see what values you get and compare them to what you are expecting to get, noting/looking into cases where the two differ.