Thread: More than one action point

1. More than one action point

So I made a little example of how to add more than one action point to an object.
This example uses no extensions, stores the value in one action, and snaps the point into place with one "always".

The idea is that when you click, the point is created - however, instead of working with complex transformations for angle changes, you store the position relative to the main object.

When you create the object, you need to measure two things: the angle of the point in relation to the mouse, and the distance of the point in relation to the hot spot of its parent object - that's all you need.

The angle is given by:
[color:#663333]ATan2((Y position of the Mouse - Y position of the parent), (X position of the parent -X position of the mouse))+(180 - Angle of the parent)[/color]
Note 1: Don't forget the comma in the expression above!
Note 2: You need to subtract the angle of the parent to 180, because of some weird issues with angles in mmf

The distance is given by:
[color:#663333]Sqr((X position of the parent - X position of the mouse)²+(Y position of the parent - Y position of the mouse)²)[/color]
Use ### pow 2 instead of ###²

Note: you don't have to create an object to store this information, you can store them into the alterable values of the object itself or somewhere else, such as a file or array

When setting the point's position, you set it's X coordinate to
[color:#663333]X position of parent + cos(angle of the point + angle of the ship)*(distance of the point to the center of the object)[/color]
and it's Y coordinate to
[color:#663333]Y position of parent - sin(angle of the point + angle of the ship)*(distance of the point to the center of the object)[/color]

2. Re: More than one action point

Great article!

I have a suggestion though - you can multiply by the scale of the parent as well:

X position of parent + cos(angle of the point + angle of the ship)*(distance of the point to the center of the object)*XScale("parent")

etc

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•