Truck with a trailer
sparkania
Member, PRO Posts: 300
I have read a few posts including http://forums.gamesalad.com/discussion/33288 on how to constrain 2 actors together.. but for some reason the options are not there in my constrain: --- to ---.
When on the Truck actor
I can constrain self.position.x to self.position.x
and y to y
when on the Trailer actor, I don't have the option to constrain to the Truck.. it's really buggin me.. Help?
When on the Truck actor
I can constrain self.position.x to self.position.x
and y to y
when on the Trailer actor, I don't have the option to constrain to the Truck.. it's really buggin me.. Help?
Comments
The second method will become tricky if you have many scenes, because you would need to add new rules to every unlocked actor separately.
Constrain Attribute game.TruckX (real) to self.position.X
Constrain Attribute game.TruckY (real) to self.position.Y
Trailer:
Constrain Attribute self.position.X to game.TruckX
Constrain Attribute self.position.Y to game.TruckY
This will force the trailer to stay at the same x/y as the truck. Keep in mind that in GameSalad, x/y coordinates refer to the center of the actor. So if you want the trailer to be behind the truck instead of on top of it, you'd need to do something like:
Constrain Attribute self.position.X to game.TruckX-100 (assuming your truck has 100 width).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
1. I select on the stage the actor I labeled 'Truck'.
2. I create 2 new 'Real' attributes. TruckX and TruckY and leave them at 0.
3. Then I go to the Backstage and drag in 2 Constrain Attribute blocks.
The first one, I select
constrain: Attributes>Truck>TruckX =(self.TruckX)
to: Attributes>Truck>Position>X =(self.position.x)
Second one
constrain: Attributes>Truck>TruckY =(self.TruckY)
to: Attributes>Truck>Position>Y =(self.position.Y)
so far so good
4. I select on the stage the actor I labeled 'Trailer'
drag in 2 Constrain Attribute blocks
The first one, I select
constrain: Attributes>Trailer>Position>X =(self.position.x)
to: Attributes>.... what? I do not have an option to pick anything labled Truck nor are the TruckX nor TruckY in the 'Game' list.
Second one
constrain: Attributes>Trailer>Position>Y =(self.position.y)
to: Attributes>.... what? I do not have an option to pick anything labled Truck nor are the TruckX nor TruckY in the 'Game' list.
is it something I should type into the fields or am I limited to that which the selection widows offer?
So like I said, I am missing something. Something that you may understand as 'Duhh' but I am still learning and there is something I am not catching..
I do understand that the constraint will lock to the middle of the actor and that +/- must be entered to land it exactly where I want it to appear..
A global/game attribute can be accessed by any actor, an actor attribute can only be accessed by that actor (unless you start unlocking your actors).
Yep! It needs to be a game attribute.
Just to be clear, I am creating an overhead-view driving game.
I have the Trailers x and y constrained to the Truck's x and y via the 2 (real) attributes.. BUT.. now they move like they are synchronized swimmers.. the trailer is not being.. "Towed" per say, nor does it rotate static to the trucks movements. it is staying in the same position relative to the truck. So I added a third constraint for the rotation, setup similar to the TruckX and TruckY.. but now when I turn, the truck rotates as it should but the trailer mirrors that same activity..
is there a way to static attach 2 actors? to make one rotate with the other, not just mirror the rotation?
No thanks.
: P
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Then add yet another actor as the 'trailer wheels' and attach them accordingly.. put a little drag on the wheels and whammo.. I only need to get constrained items to keep their position with relation to the rotation of it's parent actor..
What's in it for me ?
: )
http://forums.gamesalad.com/discussion/45895/pseudo-joint-and-rotation-problems
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
However, to be on the safe side perhaps we should ask SSS if we need to log a bug report about this.