Game Development Community

Mounting Scrollers to SceneObjects

by C Martin · in Torque Game Builder · 10/07/2008 (4:36 am) · 3 replies

Hi Guys,

I need to mount a scroller between two moving sprites, and I need to do this through script. So i've been trying a few things out - aaand not having much luck. There are a number of issues i'm running into:

1. I can call mount on the sprite object and attach the scroller to it, but it always attaches it to the middle of the scroller. I've set two mount points in TGB - but can't find a way to specify which of the two mount points on the scroller the sprite should attach to

2. When I mount the scroller to the sprite, the sprite moves to the scroller, I can't get the scroller to attach to the sprite and move with the sprite

Thanks - any help at all would be appreciated!

Cheers :)

Edit: Removed question regarding mount being called on scroller - that was a script issue

#1
10/09/2008 (9:16 pm)
I don't have a lot of experience with mounting objects to other objects' linkpoints, but I just recently built some code that seems to work fine.

For #1, something like this ought to work for you:

// NOTE that the LinkPoint ID is actually 1 number higher than in the GameBuilder editor.
// i.e. Linkpoint 0 in the editor is actually linkpoint 1 in Script. This is what I mean by (%linkID+1)
%scroller.mountToLinkpoint(%sprite, (%linkID+1), 0, 0, 1, 1, 1);

The 0s and 1s after the %linkID should be changed according to your needs, according to what you want from the following options:

mountToLinkpoint(t2dSceneObject object, int linkpointID,[float mountForce=0],[bool trackRotation?=true],
        [bool sendToMount?=true],[bool ownedByMount?=true],[bool inheritAttributes?=true])

For #2, I'm not sure why you can't get the scroller to move to the sprite. If you set sendToMount to true, it ought to do it.
#2
10/09/2008 (9:45 pm)
If you intend to mount objB to objA, you need to call:

objB.mount(objA...);

I suspect that for #2, you had it the other way around.
#3
10/13/2008 (4:38 am)
Thanks guys - think I got it sorted out. As always, I appreciate the help! :)