Spawn Actor At Touch?

peachpellenpeachpellen Member Posts: 977
edited November -1 in Working with GS (Mac)
Here's the thing;

I want to spawn an actor every time a player touches a space inside a square.

The problem is, I want the actor to spawn in the same place the player touches; not the center of the square and not at set co-ords.

Can anyone tell me how to do this? ^-^;

Comments

  • StusAppsStusApps Member, PRO Posts: 1,352
    create new attributes called playerX and playerY, constrain these in a rule to self.touchx and self.touchy

    Select the square and edit it. Set a rule for touch pressed. When you set the spawn rule for position use the new playerX and playerY as the coordinates. This will make them spawn at your finger press position.

    Hope that makes sense.
  • peachpellenpeachpellen Member Posts: 977
    I'm not sure if it does yet or not - I'm someone who has to be in GS before I can tell if it makes sense to me or not :P

    But thank you - I shall attempt this now and let you know how it goes :)
  • peachpellenpeachpellen Member Posts: 977
    Ok, another noob question - sorry -

    These attributes - are they integers or....?

    Also with self.touchx and self.touchy - are these within the square or within the actor being spawned?

    Sorry >.<' I've never had to do this before.
  • peachpellenpeachpellen Member Posts: 977
    Ah, I got it - I don't know how, but it's working :P

    Thanks :)
  • ValanValan Member, BASIC Posts: 410
    Hi
    I use a Rule

    When all conditions are valid
    Actor receives event Touch is inside
    Attribute (Devices/Touches) Game.Touches.count) = 1

    Spawn actor
    Position x = (Devices/Touches) game.Touches.Touch 1.X
    Position y = (Devices/Touches) game.Touches.Touch 1.Y

    Note.
    Copy/Pasting this code won't work. You need to go through the GS scripting system.
Sign In or Register to comment.