Forum Replies Created

  • Daniel Russell

    October 29, 2012 at 10:46 pm in reply to: position detection

    The first idea that comes to mind is this strategy. Basically, you want to
    have a scaryDot and a crowdNull. All the important chasing/running away stuff happens between just those two objects.

    Relatively simple expressions in the individual dots that form the crowd will merely offset their position from the crowdNull.

    The first simple way of seeing this (before sprucing it up) is this: simply have the crowdNull run away from the scaryDot in two different, but blended, manners. The first manner in which it runs away is a bee line that is simply in the same direction as that from which it is chased. The second manner is veering to avoid colliding with the edges of your composition. Blend the two together using whatever mathematical factors look good.

    Hereʻs a more detailed breakdown of the steps in the code.

    1) Use a null object that is roughly in the center of the swarm.
    2) Use expressions in each of the dots to offset from the null, with some randomness using random() and associated functions. Alternatively, you can simply parent all the dots to the null and use wiggle to move them relative to it.
    3) Now, the running motion only has to happen for the null, and all the dots will follow. This is the challenging part.
    4) Calculate the unit direction vector between the scary dot and the null controller by using normalize(sub(crowdNull.position, scaryDot.position)). You will use this vector to determine the general *direction* that the crowdNull runs (and thus the crowd of dots).
    5) Now you need to account for speed, and multiply that by the unit direction vector to obtain velocity. The speed will depend on two things: a) acceleration b) the speed of the scaryDot itself, which you determine by looking at how far it has moved since previous frame to get pixels/frame.
    6) Multiply the unit direction vector by the speed you calculated using beeLineDelta = mul(direction, speed).
    7) As this deltaPosition causes the crowdNull to approach the edge of the comp, you need to veer away from the edge. ThatÊ»s the biggest “gotcha” in this code. LetÊ»s take an example. If the vector from the scaryDot to crowdNull is leaning left, then the crowdNull should probably veer left as it approaches the edge of the comp, to avoid slamming the wall.

    If I get time, I will post extracts from the code I have in mind. Itʻs, sadly, a little complex. 😉

  • Daniel Russell

    October 20, 2012 at 1:08 pm in reply to: Adding comments to layers

    I would like to know how to access these comments programmatically. I can only seem to find information about accessing markers. *confused*

    Thanks for anyone who can help me sort through the API to do this.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy