GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Transfer Physics Properties

tripleehentertainmenttripleehentertainment Posts: 52Member
edited November -1 in Working with GS (Mac)
Hello all! I have been working with GameSalad for the past 2 weeks and everything is great.

I'm kind of stuck right now - I have a physics-based game in the works, and I NEED the following feature:

I need to be able to change the collision type from rectangle to circle and vice versa.

I've looked around and found out that this is not possible.

So my make-shift solution was to have two separate actors and, when I needed to swap collision types, I would simple spawn a new actor and destroy the previous.

All is well. Except - I need to be able to give the new actor the same physical properties as the previous

For example, if i have a square sliding slowly down a hill and the user presses on this square, thereby transforming the square into a circle. I want this circle to have the same rotation and velocity/acceleration as the square just had.

Could someone explain how I could do this?

Comments

  • harrioharrio Posts: 234Member
    what's cookin,

    you'll have to do what i did for my macworld game 'jen'. it does what you are asking only you can't see it because the two actors are of the same graphic.

    you have to setup all the values you want to transfer in the game attributes area; speed/velocity, angle of velocity, size, position x/y etc. then you will have to either constrain these values to your actors or pass the values at the moment that they must switch. you can decide which is best for your game. depending on how your game is structured you may have to setup values for each actor in play. like i had to do; velocity1, velocity2 etc for every actor.

    hope this is clear enough for you. if not. let me know and i'll explain it further.

    noodles...
  • How could I only do something (update the actors properties to the game attributes) only once and only when the actor is first loaded?

    And also, exactly what variables will i need to pass? So for i pass X/Y, size, and the X and Y of linear velocity.

    **EDIT

    I am looking to keep the previous motion. so if the square is moving quickly to the left, I want that motion to continue
  • harrioharrio Posts: 234Member
    what's cookin,

    you would assign the values of the present actor to the game attributes you need, then remove the present actor and replace it with the other actor using the values from the game attributes you just assigned.

    you may need the self.speed, angle of velocity as well as the ones you have listed. it really depends on what you are doing as to which ones are necessary for you.

    hope that helps.

    noodles...
  • firemaplegamesfiremaplegames Posts: 3,206Member
    yes, you will need to create global game attributes that hold all of those properties...
    i.e.:

    game.PlayerRotation
    game.PlayerVelocity
    game.PlayerX
    game.PlayerY

    And in the player actor, you need to have Constrain Attributes for each of those properties.
    i.e.:

    Constrain Attribute
    game.PlayerRotation = self.Rotation
    game.PlayerX = self.Position.X

    When you spawn the second Actor,
    You'll use the global game Attributes to set the new Actor's properties

    So at the top of the spawned actor, you'll use A bunch of Change Attributes, liek this:

    Change Attribute
    self.Rotation to game.PlayerRotation
    self.PositionX to game.PlayerX

    etc.. etc..

    The behaviors of each of the Actors will look like this:

    Change Attribute
    Change Attribute
    Change Attribute
    Change Attribute
    Constrain Attribute
    Constrain Attribute
    Constrain Attribute
    Constrain Attribute
    etc..

    Does that make sense?
    Joe
  • Yes that makes absolute sence. The only problem I have now is how would I keep the exact motion?

    Setting rotation and size and whatnot works perfect, but I'm confused as to how I would keep the velocity and MOVEMENT in rotation, not just the angle itself.
  • firemaplegamesfiremaplegames Posts: 3,206Member
    Yes, that is a little complicated, I used something similar in my magnitude demo here:

    http://gamesalad.com/game/play/31279

    It's using some pretty tricky math to keep the balls moving at a constant speed.
    Feel free to dig through it. It will show up under "Shared Games" in your desktop app. Just search for "magnitude".
This discussion has been closed.