Random not being Random

brett-nortonbrett-norton Member, BASIC Posts: 64

Hey all,

Anyone know why my random spawner not playing nicely?

I have a timer set to random 1, 3 seconds run to completion checked and it seems to be stuck spawning on the same number.

the objects being spawned have the following code in them, but noted that when trying to spawn an empty character it also does the same.

Code in the actor being spawned is-

Constrain - Self.pos.x to 100cos(self.time75%360)+game.EarthX
Constrain - Self.pos.x to 100sin(self.time75%360)+game.EarthX)
Constrain - VectorToAngle(game.eartyX-self.positionX,game.earthY-self.positionY)

Thanks

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    If you use an Every Timer in GameSalad, such as this...

    Timer every random(1,3) seconds

    ...the expression is evaluated once (so either 1, 2, or 3) and then that value is used for each cycle of the timer. What you need is a custom-interval timer like this:

    http://forums.gamesalad.com/discussion/comment/464547/#Comment_464547

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2017

    As an aside, Vanilla Forums software converts text surrounded by asterisks (*) to italics and removes the asterisks. Lovely, right? To avoid that, add a space before and after each asterisk:

    100 * sin

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    As an aside, Vanilla Forums software converts text surrounded by asterisks (*) to italics and removes the asterisks. Lovely, right? To avoid that, add a space before and after each asterisk:

    100 * sin

    . . . . or you can add a ` on either side . . . . .

    Like*this*.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2017

    @brett-norton said:
    Code in the actor being spawned is-

    Constrain - Self.pos.x to 100cos(self.time75%360)+game.EarthX
    Constrain - Self.pos.x to 100sin(self.time75%360)+game.EarthX)
    Constrain - VectorToAngle(game.eartyX-self.positionX,game.earthY-self.positionY)

    That code looks wrong to me, is it meant make the actor orbit around earth.X / earth.Y at a radius of 100 pixels ?

    If so then it should read . . .

    Constrain - Self.pos.X to 100*cos(self.time*75%360)+game.EarthX
    Constrain - Self.pos.Y to 100*sin(self.time*75%360)+game.EarthY
    Constrain - [rotation to] VectorToAngle(game.eartyX-self.positionX,game.earthY-self.positionY)

    That's - no bracket after Earth.Y / second constrain should be Y rather than X.

    you can further slim it down to . . .

    Constrain - Self.pos.X to 100*cos(self.time*75)+game.EarthX
    Constrain - Self.pos.Y to 100*sin(self.time*75)+game.EarthY
    Constrain - rotation to self.time*75

Sign In or Register to comment.