Spawner help

edited October 2012 in Help request
To help myself learn, I'm doing a basic "missle" type sprite.

I'm using a spawner for the rocket thrust effect behind the missile. Two questions:

1) The spawner uses the ObjectSpeed parameter to make the particles move (right to left). The spawner itself is a child of the missile object. When I rotate the missile, the location of the spawner changes (remains near the rocket cone of the missle), but the spawner itself still spews objects in the same direction. Is there a way to the ObjectSpeed vector track the spawner rotation (if any)?

2) The ObjectSpeed parameter for Spawners doesn't appear to allow random values like you can with the "Speed" parameter does for objects; is this intentional? Am I missing something?

Config pasted below



[Display]
ScreenWidth = 800
ScreenHeight = 600
Title = Stand Alone/Locale Tutorial

[Input]
SetList = MainInput

[MainInput]
KEY_F12 = Screenshot
KEY_ESCAPE = Quit
KEY_SPACE = CycleLanguage
MOUSE_LEFT = CycleLanguage

[Viewport]
Camera = Camera
BackgroundColor = (20, 10, 10)

[Camera]
; We use the same size for the camera than our display on screen so as to obtain a 1:1 ratio
FrustumWidth = @Display.ScreenWidth
FrustumHeight = @Display.ScreenHeight
FrustumFar = 2.0
Position = (0.0, 0.0, -1.0)

[Physics]
Gravity = (0.0, 9.81, 0.0)

[MissileGraphic]
Texture = img/missile.png
Pivot = (50, 100, 0)
TextureSize = (285, 200, 0)

[MissileFrame1@MissileGraphic]
TextureCorner = (0, 0, 0)

[MissileFrame2@MissileGraphic]
TextureCorner = (0, 200, 0)

[MissileAnim]
KeyData1 = MissileFrame1
KeyDuration1 = 0.1
KeyData2 = MissileFrame2
KeyDuration2 = 0.9

[MissileTrans]
Source = MissileAnim
Destination = MissileAnim


[MissileAnimSet]
AnimationList = MissileAnim
LinkList = MissileTrans


[MissileObject]
ChildList = HellFire # Fire2
Graphic = MissileGraphic
AnimationSet = MissileAnimSet
Smoothing = true
Scale = 0.3
Rotation = 45

[Target]
ChildList = MissileObject

[FireGraphic]
Texture = "img/fireball.png"
Pivot = center

[HellFire]
Spawner =MissileFireSpawner

[MissileFireSpawner]
Position = (-100, 0, 0)
Object = Fire
WaveSize = 10
WaveDelay = 0.05
ObjectSpeed = (-70, 50, 0.0 ) ~ (-60.0, -50.0, 0.0)

[FireGraphic2]
Texture = img/fire.png

[Fire2]
Graphic = FireGraphic2
Pivot = center
Location = (0, -100, 0)

[Fire]
Graphic = FireGraphic
FXList = FireFX
Position = (0,0,0) ~ (0, 0, 0)
Scale = .7
LifeTime = 5.0
;Speed = (-70, 5.0, 0.0 ) ~ (-60.0, -5.0, 0.0)

[FireFX]
;SlotList = SlowFadeIn # SlowFadeOut # ZFade
SlotList = ZFade # SlowFadeOut # EmbiggenFX


[MissileBipSound]
Sound = snd/bip.wav
KeepInCache = true
Volume = 0.1

[ZFade]
Type = position
StartTime = 0
StartValue = (0 , 0, 0)
EndValue = (0 , 0, 1)
Curve = linear
EndTime = @Fire.LifeTime

[EmbiggenFX]
Type = scale
Curve = linear
StartTime = .2
EndTime = @Fire.LifeTime
StartValue = 1
EndValue = 7

[SlowFadeIn]
Type = alpha
Curve = linear
StartTime = 0
EndTime = 2
Absolute = true
StartValue = 0
EndValue = 1

[SlowFadeOut]
Type = alpha
Curve = linear
StartTime = 2
EndTime = @Fire.LifeTime
Absolute = true
StartValue = @SlowFadeIn.EndValue
EndValue = @SlowFadeIn.StartValue

Comments

  • edited October 2012
    The spawner property UseRotation will allow you to transfer rotation from the spawner's parent to your spawned object.
    The property UseRelativeSpeed will also make sure the ObjectSpeed is calculated using the spawner's rotation & scale.

    Lastly, the random will take place at the spawner's initialization, not for every spawn, for performance sake.
    One way of obtaining a random speed would be to set the speed not from the spawner but directly on the spawned object instead.
    You can also listen to the orxSPAWNER_EVENT_SPAWN event and modify any property of the spawned object there.
  • edited October 2012
    Note: Somehow I managed to attach a picture of my son. =)
    The spawner property UseRotation will allow you to transfer rotation from the spawner's parent to your spawned object.
    The property UseRelativeSpeed will also make sure the ObjectSpeed is calculated using the spawner's rotation & scale.

    So, my hierarchy before was

    [Object X](missle object)
    ChildList = Y

    [Object Y]
    Spawner = Z

    [Object Z]
    WaveSize = 3
    ...etc...


    Adding UseRelativeSpeed to Z or Y did not work with this setup.

    Here's what sort-of worked:

    [Object X]
    ChildList=Z

    [Object Z]
    UseSelfAsParent=true
    Spawner = Z (this line also works when in X)
    UseRelativeSpeed=false
    UseRotation=false
    WaveSize = 3
    ... etc ...

    Here's what I want to do:

    1) Particle speed vector multiplied by normalized spawner rotation vector, so that particles emit in the correct direction.

    2) particle speed vector multiplied by current spawner speed only when generated. As it is now, if the spawner accelerates, then emitted particles speed up with it in the same direction.

    Is there a way to achieve the above using a config file ? final1.jpg
    final1 159.2K
  • edited October 2012
    epoulsen wrote:
    Note: Somehow I managed to attach a picture of my son. =)
    Hi to your son! :)
    Adding UseRelativeSpeed to Z or Y did not work with this setup.
    I just did a quick test locally using the same hierarchy and obtained the result you were looking to get with 1).
    Here's what sort-of worked:

    [Object X]
    ChildList=Z

    [Object Z]
    UseSelfAsParent=true
    Spawner = Z (this line also works when in X)
    UseRelativeSpeed=false
    UseRotation=false
    WaveSize = 3
    ... etc ...

    In this setup, the particle will be a child of the spawner and will follow it everywhere, which is probably not what you want.
    Here's what I want to do:

    1) Particle speed vector multiplied by normalized spawner rotation vector, so that particles emit in the correct direction.
    I got that result with a very simple test using, on the spawner, UseRotation = true, UseRelativeSpeed = true, ObjectSpeed = (...).
    The main issue being that you don't get a random for the speed with this setup.
    That can be partially faked by applying a very fast rotation twist on the parent object, but you'll need to spawn only 1 item at a time in that case.
    2) particle speed vector multiplied by current spawner speed only when generated. As it is now, if the spawner accelerates, then emitted particles speed up with it in the same direction.
    What you want is to have additive speed here, not multiply. However I don't see any way to achieve this without having to write some code to update your object's speed relative to its parent one. And even in that case, the speed value itself might not be on the direct parent but somewhere higher up in the object hierarchy.
    When I'll get to add vector/math commands, you should be able to realize this using a timeline on your spawned object, but for now, I don't see any code-free way.

    Now that I think of it, most, if not all, rocket smoke trails I've seen in games do not accurately use a relative speed and I've never found it to be shocking. ;)

    If you can't get to have 1) working, don't hesitate to post your whole project for us to have a look, it's usually easier than trying to replicate the situation locally.
  • edited October 2012
    Actually, there's a way to get some random on the spawned object's speed by using a timeline if you sync the latest version of orx I just pushed a minute ago. :)

    Here's the relevant part of the config:
    [Parent]
    ChildList = Child
    
    [Child]
    Spawner = Spawner
    
    [Spawner] ; No Speed set here
    Object       = Particle
    WaveSize     = 10
    WaveDelay    = 0.05
    Position     = (0, 100, 0)
    UseRotation  = true
    
    [Particle] ; No Speed set here
    TrackList = RandomSpeedTrack
    
    [RandomSpeedTrack]
    SpeedValue = (-10, 100, 0) # (0, 100, 0) # (10, 100, 0)
    0 = > Config.GetValue RandomSpeedTrack SpeedValue # ; Gets a random value from the list above and push it on stack
          Object.SetSpeed ^ < true ; Pops the value from the stack and set it as relative speed on the object
    
  • edited October 2012
    In this setup, the particle will be a child of the spawner and will follow it everywhere, which is probably not what you want.
    Exactly.
    I got that result with a very simple test using, on the spawner, UseRotation = true, UseRelativeSpeed = true, ObjectSpeed = (...).
    The main issue being that you don't get a random for the speed with this setup.
    That can be partially faked by applying a very fast rotation twist on the parent object, but you'll need to spawn only 1 item at a time in that case.
    This comes the closest with minimum code. The actual coding isn't a problem, but I'd like to keep it as "data driven" as possible.

    Thanks for your help on this. :)
  • edited October 2012
    My pleasure. :)
    Also the config example with the timeline track should allow random speeds no matter how many particle you spawn per wave.
    The day I get to add vector commands, you should also be able to do 2) directly from a timeline track.
  • edited October 2012
    Where would I find a better description of how timelines work? I've poked around the forum and the wiki, but without much success.
  • edited October 2012
    I'm afraid timelines and commands have been a fairly recent addition to orx and the best resource about it is this post: https://forum.orx-project.org/discussion/3955&limit=20

    Don't hesitate if you have any questions.
    I plan to add a tutorial on menu with timelines whenever I get enough spare time, probably not very short-term future, unfortunately.
Sign In or Register to comment.