1. #1

    OPE follow object path

    For a skill game I'm making I have used an OPE to move a train along the train tracks in the original game world, which has obviously taken a fair bit of coding.

    Behind the train I have a couple of train cars which I need to make follow the same path as the train but slightly behind as if they are being towed. Now I could just copy and paste the coding for the train but with a slight delay, but I wondered if anyone had an easier solution rather than doubling up on code and using space?
    Share this post

  2. #2

    Re: OPE follow object path

    You could glue it all together into one object.
    You could us a local OPE and target everything individually with the single OPE.
    You could do something else that I've not yet though tof and added to this post.
    Share this post

  3. #3

    Re: OPE follow object path

    if you used the code from the docs from earlie rit might be best to copy it

    something else you can do is save some of te values u used from the first piece save those in a vector
    then let all other trainparts use the vector you created

    depending on the timing of the corners etc you may or may not get something shorter
    with some luck you can potentially save all values you need just in one vector and it wont be alot of work

    it will require alot of thinking though so best is just to copy if your complexity meter can handle it
    Share this post

  4. #4

    Re: OPE follow object path

    Originally Posted by Barrybarfly
    You could glue it all together into one object.
    You could us a local OPE and target everything individually with the single OPE.
    You could do something else that I've not yet though tof and added to this post.
    Glueing wont work because the train needs to turn corners and go up/down slopes ahead of the train car, and that needs to turn corners ahead of the second train car. Etc etc

    Using the same OPE will cause the train cars to turn or climb at the same time as the train, rather than follow behind it.

    Originally Posted by sparkierjonesz
    if you used the code from the docs from earlie rit might be best to copy it

    something else you can do is save some of te values u used from the first piece save those in a vector
    then let all other trainparts use the vector you created

    depending on the timing of the corners etc you may or may not get something shorter
    with some luck you can potentially save all values you need just in one vector and it wont be alot of work

    it will require alot of thinking though so best is just to copy if your complexity meter can handle it
    The code is based on the earlier problem you helped me with. I used that code for making a flight path for a plane which worked well. The train is different however as it rotates on two axis not one, and is not on a loop it only moves from A to B.

    The system uses an OPE set to local for positional movement and global for angular. At each point where the train track changes direction, there is an invisible train pointing in the new direction with the vector angle information above it, along with a world distance operator. The OPE moves the visible train from one invisible train to the next, and changes the vectors to match the new train once it gets there. This means I can alter the path of my train by moving the invisible trains around and I don't have to change any coordinates.

    My complexity meter is doing ok, but I like to keep coding to a minimum to improve overall performance, just as a general rule. If I have to copy it its no biggy.
    Share this post

  5. #5

    Re: OPE follow object path

    ok i see

    the main problem of vector is that it can only hold 1000 values and if you have no idea about the timing of the curves then you will need to use a new vector every 16.66sec
    and sadly there is no easy way to retarget datascoures or so to get the values

    so if its a long drive for the train you would need to use to much datasources
    however any repetiveness can seriously reduce the coding

    the repetiveness can be as simple as it only turns on even ticks

    how did you do the coding to get the next invisible trains vector?
    Share this post

  6. #6

    Re: OPE follow object path

    Originally Posted by sparkierjonesz
    how did you do the coding to get the next invisible trains vector?
    I used a series of Set Vector Events which get the vectors from Vector Info Data Sources linked to each train. Each invisible train effectively points towards the next one in the sequence. A world distance operator gives the distance to the next train, which feeds into the amount of ticks along the x axis the train moves before the next Set Vector Event is triggered.

    It's not as smooth as I'd like as the cornering is jerky. If I was making some kind of train based game I'd take more care but it's for use in a combat flight simulator and the character will be flying overhead in a jet and probably not notice it that much.

    What I really need for this is a delay filter for information rather than impulses, then I could just split the signal from the OPE and delay it to use on the train cars.
    Share this post

  7. #7

    Re: OPE follow object path

    then i guess its your lucky day because i already have one
    it only can store tha values from 0 to 16.6 sec ago but i guess thats alright

    just use a set vector to store the values of the datascource u use for your 1st train and write them in a vector
    (looping cds doesn't work so good but you can make one with some operands an inteval trigger and a set event(increase 1) that constanly loops from 0->1000 over and over

    now you just need a looping get vector to get the data you need and just let it start a bit later

    in detail explanation

    ok so you need an interval trigger that triggers a set vector event each tick
    the value will be the datasources u use from the first train
    a vector with a size of 1000
    add more vectors if you want to keep track of more datasources

    now some other coding(to replace a cds)a looping cds between 0-999 in1000 ticks but rounded might also work, but might vibrate)
    interval trigger to a set event increase 1 to a vds(value 0)
    divide vds by 1000 round it(floor) and multiply by 1000 again
    then substract the vds with the multiply
    now this operand will be the index value for the set vector event

    now for the delayed trains all you need is a get vector that uses the same coding as above except you can delay it by letting the interval trigger start later(max 999 ticks later maybe even a bit less to be safe)
    because after 1000 ticks the first values will be overwritten
    Share this post

  8. #8

    Re: OPE follow object path

    Ok cool, I'll give that a try when I'm next on the box. Sounds like genius again if it works, I'll let you know.

    Thanks for the help.
    Share this post

  9. #9

    Re: OPE follow object path

    just a correction about something i said earlier

    Originally Posted by sparkierjonesz
    sadly there is no easy way to retarget datascoures or so to get the values
    an idea just poped up that actually makes this posible in a fairly easy way
    you could u probably use a vector and the get vector to make the equivalent of a selector for event targets

    write your datascources with a set vector(an index for each datascource) in a vector
    then you can use the get vector index for the datasource you want to use

    i didn't test it yet and i'm not sure if you can have several set vectors writing in the same vector at the same time
    but if it does you just created a selector for datascources than can select out of up to 1000 different datasources
    compared to the one redlynx gave than can select between 2
    also there could be a delay of 1 tick depending how the engine will deal with this
    Share this post

  10. #10
    dasraizer's Avatar Senior Member
    Join Date
    Apr 2014
    Location
    UK, Isle of Wight
    Posts
    1,195

    Re: OPE follow object path

    you can also use the retargeter on object vector infos that are pointing to a set of dummy objects that form your path, bare in mind it takes the retargeter a few ticks to settle, so you would need to double buffering the ovi to your current vds.
    Share this post