So since my last post I updated to orx 1.5 and implemented layers in my game and now everything is place on Z = 1.
But I was wondering if there is a good way to implement an effect that is one or more orbs rotating around a character. This is a pretty common effect in games, some examples I can think of are the orb effects in Warcraft 3, all the shaman's shield effect on WoW, invoker orbs on Dota and monk's spirit spheres and gunslinger's coins on Ragnarok Online.
My first idea was to implement two intervals, one making the orb move in the x and/or y axis and another in the Z axis. Is it still the best way? I would need to set all the scenario in a lower Z than the character, but still, it was my best idea.
Any suggestions are welcome.
Comments
It shouldn't be to bad using an orxFX.
The way I'd do it would be something like:
- set the character as the orb's parent
- add an offset on Y to put it at head/shoulder level (or wherever you want)
- add a looping FX that could be composed of those slots:
. sine on pos.x, large value (you'll also probably need to add an initial x offset for you object, which value will be -1/2 * the large value mentioned earlier)
. sine on pos.y, smaller value, with phase shifted by 90° (PI/2)
. square on pos.z, going from a small negative value when in front of the character to a small positive one when behind of the character, this one could actually be part of the previous slot, having a sine affecting both pos.yz
. sine on scale.xy, slightly > 1 when in front, slightly < 1 when in back
That would be pretty straightforward had we a visual curve editor, but you might have to do some trial&error if you're not used to handle FX curves yet.
As for the specific case of the invoker (video above), an extra sine on Y slightly out of phase and with a different period would be necessary to obtain the same effect. But in that case you'd need a separate FX (ie. FXList would have 2 FXs instead of one) as both FXs would have a distinct period for looping.
Add the following lines at the end of BounceAlt.ini and then run orx/bounce.
It works, the Z effect still needs some twinking, it also seems to get quite CPU intensive sometimes, but other than that is what I needed.
Thanks a lot.
For the 3 balls mentioned above, on my 4 years old machine, the FX update averages between 0.01ms and 0.02ms.
As for the Z, what problem do you encounter?
- 200 balls: ~0.58ms
- 500 balls: ~1.4ms
The problem is that the orb disapears twice while orbiting around the character (first time in the front of it, which is wrong). I will twink the numbers to get it right later. As I said I am pretty busy working on other projects, so might take a while
Thanks for the answer.
PS: 100 posts
Whenever you get a chance (no hurry, really), by turning on the profiler and the history (Scroll Lock key), you should be able to see what's going on and which function is to blame:
- Turn on profiler (Set Render ShowProfiler 1)
- Turn on history (Scroll Lock key)
- Create your object
- Pause profiler (Pause/Break key)
- Go back to the frame with the spike with left/arrow keys
- See what's going on
As for the Z disappearance that's weird as the way I set it up, the Z flip front/back should only happen on the far left and far right of the ellipsis. But I'm sure you'll find the issue.
PS: Congrats for 100!
Just wondering, is there any easy way to pre-load a texture without rendering it? My idea was to give it a non-rendered group and create an object, but it seems it would create several other attributes and my become heavy.
I'm usually using a very basic one: I keep a list of resources I want per level/map, menus, etc and simply call orxTexture_CreateFromFile/orxSound_CreateFromConfig with them.
Now that resource loading is asynchronous, you can query the resource module to know when it's done working before continuing.
You can also load separate config files per level and scan all the keys in memory for Texture/Sound/Music and load those.
I'm not sure which approach is the most appropriate for your use, but when you find one, if you feel like writing a wiki page for it it might help others.