Game Development Community

FlipX/Y properties question

by Alex Okafor · in Torque X 3D · 03/11/2007 (12:55 pm) · 13 replies

I've got a scene object with a mounted child on it with some offset and such. When I set the FlipX property to true on the parent, it seems the rotations for the children mounts go backwards (keep their same rotational direction). I've set the inheritMountFlip to true also. When I set both Flipx and FlipY to true it works once again. It seems I can't use them independently. So for times when I'm just flipping the x I have to set the rotation to -rotation to get it to look correct. Any info on how flipX/Y is supposed to work or is this a bug?

#1
03/12/2007 (4:32 pm)
Can I ask what version of TorqueX you are using?
#2
03/12/2007 (4:45 pm)
Version: 1.0.2.8.
#3
03/13/2007 (8:00 am)
That sounds similar to flash. When you flip an object horizontally, its rotation has to be flipped too. Maybe it was designed that way. In flash you flip an object horontally or vertically by giving it a negative size...
#4
03/13/2007 (2:07 pm)
Alex,
I'm having a little trouble following you. Could you please explain again in a little more detail.

One thing I don't understand is you can't have a negative rotation. At least, the editor won't let you specify a negative number. For instance, if you put -90 in the rotation field, it will convert it to 270.

What do you mean by 'go backwards' ?


BTW. Is this what you are seeing? When you tell a parent to FlipX or FlipY, the child is not flipping? If this is the case, then we have resolved the issue and should go out with the next update.
#5
03/13/2007 (2:20 pm)
Well, if I'm following you correct it looks like this is a non-issue in our internal build. If I set the parent to auto rotate the mounted child rotates correctly with it.
#6
03/13/2007 (2:53 pm)
I just created a quick video example of what I'm seeing. Both segments are identical except for the parent.flipX = true in the 2nd segment.

www.paradeofrain.com/misc/fliptest.wmv

this is the mounting code in BeginRun()
_plr.LinkPoints.AddLinkPoint("center", Vector2.Zero, 0);
            _block.Mount(_plr, "center", new Vector2(0, -3), 0, true);
            _block.InheritMountFlip = true;
            _plr.FlipX = true;

and here's the link rotation code in update.
_plr.LinkPoints.AddLinkPoint("center", Vector2.Zero, _rot);
            _rot++;

While I understand in this example I could get around this issue by setting _plr.Rotation. But in my other project I'm trying to achieve 'joint' behavior and allow objects to rotate on an arbitrary point. I was hoping this way would work so I wouldn't have to create tiny sceneObjects to act as joints between two images, instead just rotating the linkpoint.

Am I going about this the wrong way?
#7
03/14/2007 (7:53 am)
In this example, is the GG logo the parent?

www.mmogamedev.info/images/imgdc_ad1.gif
#8
03/14/2007 (11:38 am)
Yes it is
#9
03/14/2007 (1:16 pm)
I'll try to set aside some time to play with this tonight if you don't get an answer.

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#10
03/14/2007 (5:06 pm)
If I'm following you correctly, your doing the below code every update?
_plr.LinkPoints.AddLinkPoint("center", Vector2.Zero, _rot);
_rot++;

If this is the case, there is a much easier way to get an object to rotate around another:
1. Create three objects: sprite1, sprite2, and an empty T2DSceneObject.
2. Mount the empty T2DSceneObject to sprite1 and set TrackMountRotation to false
3. Mount sprite2 to the empty T2DSceneObject with an appropriate offset.
4. Add a T2DPhysicsComponent to sprite2 with an appropriate AngularVelocity.

Example movie
#11
03/14/2007 (7:15 pm)
T2dPhysicsComponent ... hrm ... *looks that one up ....*
#12
03/14/2007 (10:18 pm)
Hi Robert,
Thanks for the reply. I imagined I would have to use an empty scene object between two others if this way didn't work. I'm trying to create a basic 2D skeleton-like animation system on top of torqueX so that I can animate bodies in an editor, and then use that data to animate game objects in the game. The view is a side/profile view, which is why flipX came up. I was hoping to animate things with a single side and simply flip the object's x to get the opposite side with no additional animation data. The video you posted didn't seem to convey that, but I failed to mention my target goal earlier I suppose. I got the behavior I was looking for by modifying how link points rotate, and below is video that illustrates it, but I'd like to hear from you on whether or not FlipX is supposed to behave this way (in regards to flipping children also).

I didn't know the T2DPhysicsComponent would allow me to rotate objects like that around link points. That'll be very helpful in key framing. Thank you for that heads up!

FlipX video 'correct'
#13
03/14/2007 (11:28 pm)
I'm sorry Alex, but I just mounted like 14 objects, onto one, and they were flipping and rotating fine.

heres my code.. This probobly wasn't proper use of torque X, I created my own mounting component and there is probobly a mounting component somewhere in torqueX i could have used or something.. but heres what I did.
_mountObj = (T2DStaticSprite)(TorqueObjectDatabase.Instance.FindObject(_mounty));
                        T2DLinkPointComponent myPoint = _mountObj.Components.FindComponent<T2DLinkPointComponent>();
                        SceneObject.Mount(_mountObj, _mountPoint, true);
                        SceneObject.TrackMountRotation = false;
                        SceneObject.InheritMountFlip = true ;
                     
                        _mounted = true;