Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: more options for Parenting strategy #2

Open
slimshader opened this issue Oct 29, 2019 · 1 comment
Open

Feature request: more options for Parenting strategy #2

slimshader opened this issue Oct 29, 2019 · 1 comment

Comments

@slimshader
Copy link

It would be really useful if Parenting strategy feature allow for target position and rotation offsets.

@all-iver
Copy link
Owner

all-iver commented Oct 30, 2019

This kind of thing is what transitioners are for. In the parenting attach strategy, add a flexible transitioner for the child (this says what the child will do when it joins the attachment). Then you want to set the Position Behavior to Snap, which means the child's position will move so that an anchor on the child is on top of an anchor on the parent. It should look something like this (most of this is just the default values):

x2YAKZ

Then if you want to adjust the anchor positions, you need to define the "params" which are just Vector3 variables that say what xyz offsets the two anchors are at. When attaching, the transitioner will look for a Vector3 param called "position" on the parent, and another Vector3 param called "position" on the child (you could change the names to "offset" or something too).

You have a few options for where to put the params:

  1. Set the default values in the strategy itself (and set the "Relative To" as desired). This is easiest if every object using the strategy has the same offset.

  2. Add them to "default params" in the Attacher. For instance, add a Vector3 param called "position" to the parent object in the Attacher.

  3. Add an AttachPoint to the objects themselves. For instance, add an AttachPoint component to the parent, then create a Vector3 param called "position".

This is really complicated to describe but it's actually pretty easy to do. :) Hopefully it makes sense. You can do the same thing for the rotation, just set the rotation behavior in the transitioner to Snap and then declare a param somewhere to say what the angles should be. You could also write your own transitioner to simplify this a lot, the flexible one is just there to cover a lot of common cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants