ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Follow moving objects in 3D space

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Albert Kowalski
Follow moving objects in 3D space
on Nov 6, 2017 at 10:27:36 am

Hi!

I am trying to figure out if this is possible. I created a simple solar system. Planets are orbiting the sun this way: every planet is parent to a 3D null that is positioned in the center and rotates infinitly. Planets are created with CC Sphere effect and their layers are also 3D. What I'm trying to do is somehow make the camera move closer to one of the planet and then follow its orbital movement. That way I'll be able to jump from one planet to the other and follow their tracks. I looked up the plugin from VC called Sure Target, but from what I understand it only follow the static objects. I also tried to parent the camera to certain planet null but it doesn't work at all. Any ideas?



Return to posts index

DeMarc Johnson
Re: Follow moving objects in 3D space
on Nov 8, 2017 at 1:17:18 am

Sure Target should work. Sure Target allows you to pick a target/3D layer and go from one layer to the next regardless of if it's static or not, but for some reason that is not the case try this.

Create a null object
Create a camera and parent the camera to the null.
Separate the dimensions of the null position for more control.
Create a Slider Control and set the max value to 1 less than the amount of planets you have.

var Mars = thisComp.layer("Camera Control").effect("Layer Control")("Layer"); //Create a Layer Control in the null object or pick whip each planet position and put it in a variable.
var control = thisComp.layer("Camera Control").effect("Layer Control 2")("Layer"); //Create a Layer Control in the null object for this layer or get this layer position.
var Earth = thisComp.layer("Camera Control").effect("Layer Control 3")("Layer");
var arrList = [control, Mars, Earth]; //Put all of the variables of the planets and the null object in this array.
var planetAmount = arrList.length;
var slider = thisComp.layer("Camera Control").effect("Layer List")("Slider");
var prevTarget = Math.floor(slider); //This will get the previous target number in the array in slider
var nextTarget = Math.ceil(slider); //This will get the next target number in the array in the slider
var sliderLimit = Fslider === planetAmount - 1 ? 0 : 1; //This will prevent slider from going beyond the array object.
var prevTargetPos = arrList[Fslider].transform.position.value; //If you choose to pick whip the position of the planets then get rid of transform.position.value and do the same with nextTargetPos
var nextTargetPos = arrList[Fslider + sliderLimit].transform.position.value;
linear(slider, prevTarget, nextTarget, prevTargetPos, nextTargetPos);


If you want a sudden zoom from one parent to the next, then use the Math.floor() method on the slider in the linear method.

Rather you chose to pick whip the planets and null's position or use the Layer Control, stick with that one choice for all of the planets and null variable or else the code will break.

For Expression Tutorials:
https://www.youtube.com/channel/UCe77szX2n1WSKsGs-2gmbDw


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]