Game Development Community

Change mounting points?

by Azmodeus · in Torque Game Builder · 09/26/2006 (12:58 am) · 14 replies

Ok so I've created my particle. The emitter is based on LineY. However, when I try to mount it, it always mounts from the center of the particle object. How can I move the mounting point?

#1
09/26/2006 (1:00 am)
Update.


I can use a offset to move it around, however, the "size" and "offset" do not seem to match.

Ie, if I create my particle with setWidth(50) and then mount it with offset "50 0" it is nowhere NEAR my player. It is way way way in front. Is there some kind of conversion that needs to be done?


So basically, it would be better if I could somehow move the mounting point of the particle from the center to a specific point.
#2
09/26/2006 (1:16 am)
The mount position is specified relative to your object's size, position and rotation. If you want the effect to be mounted on the right side of your player mount it to the position "1 0" for example.

Here is some reference:
tdn.garagegames.com/wiki/TGB/Reference:_Glossary#Object_Space
#3
09/26/2006 (1:24 am)
Ahh.. yes, I'm learning. :)

I can set the link point. It had me confused, because you mount it not link it. Should have called the function setMountPoint.

What you wrote above is fine for where to place it on the player. But the problem was it was then centered on the player and not offset (the particle itself).

I figgured out that link points are where the mount points go. Once I made that connection it became clearer.
#4
09/26/2006 (1:25 am)
PS that link takes me to the forums, not sure why, but I found it.
#5
09/26/2006 (1:27 am)
Quote:
PS that link takes me to the forums, not sure why, but I found it.

Yeah, you're right. Anyway, the link goes to the TGB reference on TDN.
#6
09/26/2006 (1:38 am)
Arg, I thought I was on to something.

But still no joy.

My particle is still mounting from the center of the particle.

Even after I set the link point.

Ie., its mounting to the correct spot on the player, but the particle is still centered on the player.

ie - will be my particle. and x will be my player. This is what I see.

------X------


This is because my emitter is based on the LineX parameter. The emitter is mounting to the player correctly, but I dont want it to mount from the center of the emitter/particle. I want to mout it from the end. If I use an offset, the scales are all different from the offset and the size of the particle.

now I'm guessing that there is a way to mount it from the link point on my particle to the mounting offset that I choose.

Just trying to find out. I guess i'll try digging around in the dox and see what I can find.
#7
09/26/2006 (2:35 am)
Unfortunately that's a problem with the way that mounting works. Because of the physics calculations, pivot points are set in the middle of objects, so mounting two objects aligns their central points. Setting the offset just tells TGB how far over the child should be mounted on the parent, so you have the centre of the child mounted to the offset point on the parent.

You can use multiples (such as "0 2") to push the mounts out past the width of the parent, but that's all. Maybe with some fancy C+_ coding you could adjust the engine to get the results that you want, but it's not something that can be done out of the box.
#8
09/26/2006 (1:17 pm)
Hmm.. I'll have to see if i can create a different particle effect then.

I'm trying to create a "beam laser" type of effect shooting from the player to an enemy.

Is there any sort of conversion routines for the setWidth/setHeight functions to the offset when mounting?

Ie, is the setSize creating it based on pixels? and the offsets is based on ??? Maybe there is a conversion from pixels to world coordinates?
#9
09/26/2006 (1:26 pm)
Maybe I missed something, why can't you mount the particle to a point outside your player?

Particle: ---.--- (where . is the center)
Player: . X (where . is the mount point)

So when you combine them the mount point lines up with the center of the particle
Mounted ---.---X

Or better yet, build your particle like this: ------.
#10
09/26/2006 (1:57 pm)
Yes I can. However I cant calculate the correct position to do it.

Ie, if i create my particle with setWidth(50)

and then my offset for this is "6.0 0"

This was found by manually tweaking it over and over and for a stationary object.

So the width of my particle in "world" corrdinates is 12.0 and the width in particle coordinates is 50.

Was hoping I guess that there was a simple way to convert from one to the other so I could calculate it.
#11
09/26/2006 (2:01 pm)
Look into the APIs in TGB for something like "getLocalPoint(%worldPoint)" or similar. You can use that to pass in absolute coordinates to an object and get the object space coords back out.
#12
09/26/2006 (2:01 pm)
Mounting is done with normalised coords. The X axis is -1 left, 0 is centre, 1 is right. setSize is done with world units (unless your camera/res settings are the same in which case they are equivalent to pixels).
#13
09/26/2006 (2:06 pm)
Whoot, I figgured it out.

When I created my player I gave it a "size". That size ("8 8") = ranges from -1 to 1 in world coordinates. So I can calculate how much "50" is based on the size of the player. Ie 50/8 = 6.25
It is all starting to make sense now.

Sorry for all the hassle, but I'm very new to TGB. :)
#14
09/26/2006 (2:14 pm)
Yes, if you don't want to use the built in tools TGB provides for doing the conversion then you can calculate it manually just like that.

Glad you're getting the hang of it!