Questions about generating new actor instances

How do I set new instances of actor in position x and y? Where x and y are randomly generated coordinates within my scene.

Can I add an additional attribute to an actor to track certain values like number of hits taken etc?

Also what is the best way to increase speed of all actors at one? (e.g. like in Pacman when all the enemies speed up)

Any advice or tips appreciated

Cheers!

Comments

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @offtheradar said:
    How do I set new instances of actor in position x and y? Where x and y are randomly generated coordinates within my scene.

    You can have a Spawn Actor behaviour to spawn new instances of the desired actor.
    To have it randomly positioned, you change the x and y spawn coordinates in the behaviour to: random(min,max).

    For example if you are using iPad Landscape size you would do random(0,1024) for the X coordinate and random(0,768) for the Y coordinate.

    @offtheradar said:
    Can I add an additional attribute to an actor to track certain values like number of hits taken etc?

    Yes. You can make it either a game attribute or an actor one. If you want to make it an actor attribute, select the actor prototype, go to the actor tab press the + button to add a new attribute and choose the appropriate type (e.g. Integer for number of hits taken)

    @offtheradar said:
    Also what is the best way to increase speed of all actors at one? (e.g. like in Pacman when all the enemies speed up)

    This is actually fairly simple. I've had to do something similar in one of my games.

    First create a real game attribute called 'Speed' and set its value to the default speed you want your actor moving.
    Let's say that the actors you want to speed up are the Ghosts in Pacman; in the ghost actor prototype, they will have a Move behaviour. Instead of giving it a fixed number, set up the Ghost to move at a speed of game.Speed.

    Let's also say that you want to double the speed of all the ghosts after 15 seconds.
    Create a timer in your game rules that says 'After 15 seconds: Change Attribute: game.Speed to game.Speed*2

    Or if you want a more gradual speed increase, create a Timer that says: Every 1 second, Change Attribute: game.Speed to game.Speed+1

    Hopefully this all makes sense. If you have any questions feel free to ask :)

    Good luck!
    Daniel

Sign In or Register to comment.