Orb rotating around the character effect

edited May 2014 in Help request
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

  • edited May 2014
    Assuming it's this kind of effect you want (I had to google it ;)):

    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. :)
  • edited May 2014
    The emphasis being on setting the orb as a child of the character, this way you only work with relative values (ie. around Z = 0) and where the character scaled/rotated, the orbs would follow.

    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.
  • edited May 2014
    Here's a quick & dirty test for you to tweak.

    Add the following lines at the end of BounceAlt.ini and then run orx/bounce.
    [ParticleSource]
    Spawner   =
    Graphic   = WallGraphic
    Color     = (255, 255, 255)
    FXList    =
    ChildList = Orb
    
    [Orb]
    Graphic = @
    Texture = o.png
    Pivot = center truncate
    Color   = (0, 255, 0)
    Position = (-150, 0, 0)
    FXList  = Orbitate
    
    [Orbitate]
    SlotList = Orb-X # Orb-YZ # Orb-Scale
    Loop     = true
    
    [Orb-X]
    Type = position
    Curve = sine
    StartTime = 0
    EndTime = 2
    StartValue = (0, 0, 0)
    EndValue = (300, 0, 0)
    
    [Orb-YZ@Orb-X]
    Phase = 0.25
    StartValue = (0, -50, +0.1)
    EndValue = (0, 50, -0.1)
    
    [Orb-Scale@Orb-YZ]
    Type = scale
    StartValue = 0.85
    EndValue = 1.15
    
  • edited May 2014
    This version is slightly more fun (sorry for the spam! :)):
    [ParticleSource]
    Spawner   =
    Graphic   = WallGraphic
    Color     = (255, 255, 255)
    FXList    =
    TrackList = OrbSpawn
    
    [OrbSpawn]
    1    = >>>Object.Create Orb # Object.SetParent < ^ # Object.SetOwner < ^ # Object.SetColor < (255, 0, 0)
    1.66 = >>>Object.Create Orb # Object.SetParent < ^ # Object.SetOwner < ^ # Object.SetColor < (0, 255, 0)
    2.33 = >>>Object.Create Orb # Object.SetParent < ^ # Object.SetOwner < ^ # Object.SetColor < (0, 0, 255)
    
    [Orb]
    Graphic = @
    Texture = o.png
    Pivot = center truncate
    Position = (-150, 0, 0)
    FXList  = Orbitate # FadeIn
    
    [Orbitate]
    SlotList = Orb-X # Orb-YZ # Orb-Scale
    Loop     = true
    
    [Orb-X]
    Type = position
    Curve = sine
    StartTime = 0
    EndTime = 2
    StartValue = (0, 0, 0)
    EndValue = (300, 0, 0)
    
    [Orb-YZ@Orb-X]
    Phase = 0.25
    StartValue = (0, -50, +0.1)
    EndValue = (0, 50, -0.1)
    
    [Orb-Scale@Orb-YZ]
    Type = scale
    StartValue = 0.85
    EndValue = 1.15
    
  • edited June 2014
    Sorry for the delay, I have been really busy working on some other projects.

    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.
  • edited June 2014
    It shouldn't get CPU intensive unless you have hundreds of them at the same time.

    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?
  • edited June 2014
    Did some other quick benchmark tests:

    - 200 balls: ~0.58ms
    - 500 balls: ~1.4ms
  • edited June 2014
    Doing some tests I found the FPS drop happens on the creating of the object with the effects. When the Orb is created the FPS drops from 75 to ~45, this is on the PC I use at work, thus it has an onboard GPU. Still, it is the first time I have a noticeable FPS drop in a simple scene, that is the reason I found it strange (my other game had loads of particle effects and it was pretty smooth).

    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 :)
  • edited June 2014
    Mmh, I see. Could it be because your objects need to load their data from disk as they're not already in memory (texture, sound, ...)?

    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! ;)
  • edited June 2014
    It is possible...
    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.
  • edited June 2014
    That's one option, yes.

    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. :)
Sign In or Register to comment.