Jump to content

Object to move along a spline


cypher2012

Recommended Posts

Is there any way to create a spline in the creation kit, that you can use to have an object move along?

 

I would like to go back to my monorail mod. I've tried a couple of approaches. I've tried animating the route of the monorail in the modelling software. This worked for small scale, but my monorail goes across the commonwealth. I've also tried giving the train an array of move to locations. This kind of worked, but it was pretty choppy.

 

The ideal solution, would be to lay out a spline in the creation kit, and have the train follow the spline. Is there any way to do this?

Link to comment
Share on other sites

How did you make it move? I'm trying to get a light source to move on a path or patrol but have not figured out how to do it.

 

It was a pretty robust method. I used a bunch of X-markers. My train then held an array that referenced each of those markers. It would loop through the array. Moving to the next marker once it completed moving to the current one. It SORT OF worked, but it was very clunky. It was a bit of a bodge!

Scriptname CMR:CMR_TrainOnly extends ObjectReference
{Script which actually controls the trains travel
}

ObjectReference[] Property TrackPoints Auto
ObjectReference Property PlayerXEntryMarker Auto
ObjectReference Property PlayerXExitMarker Auto

Float fMonorailSpeed = 500.0
Int iTrackIndex = 1

Function RunTrain()
    Debug.Notification("Function: RunTrain called.")

    ;Move train to start
    Self.MoveTo(TrackPoints[0])

    ;Move player in to the train
    Game.GetPlayer().MoveTo(PlayerXEntryMarker)

    ;Start moving the train towards the first track point
    Self.TranslateToRef(TrackPoints[1], fMonorailSpeed)
EndFunction

Event OnTranslationComplete()
    Debug.Notification("OnTranslationComplete event called.")
    FindNextPoint()
EndEvent

Function FindNextPoint()
    Debug.Notification("Function: FindNextPoint called.")
    iTrackIndex += 1

    ;Check to see if there are any more track points. Otherwise, end of line
    If(iTrackIndex >= TrackPoints.Length)
	EndOfLine()
    Else
	;Move to the next track point
	Self.TranslateToRef(TrackPoints[iTrackIndex], fMonorailSpeed)
    EndIf
EndFunction

Function EndOfLine()
    Debug.Notification("Function: EndOfLine called.")
    iTrackIndex = 1
    Game.GetPlayer().MoveTo(PlayerXExitMarker)
EndFunction
Edited by cypher2012
Link to comment
Share on other sites

 

How did you make it move? I'm trying to get a light source to move on a path or patrol but have not figured out how to do it.

 

It was a pretty robust method. I used a bunch of X-markers. My train then held an array that referenced each of those markers. It would loop through the array. Moving to the next marker once it completed moving to the current one. It SORT OF worked, but it was very clunky. It was a bit of a bodge!

Scriptname CMR:CMR_TrainOnly extends ObjectReference
{Script which actually controls the trains travel
}

ObjectReference[] Property TrackPoints Auto
ObjectReference Property PlayerXEntryMarker Auto
ObjectReference Property PlayerXExitMarker Auto

Float fMonorailSpeed = 500.0
Int iTrackIndex = 1

Function RunTrain()
    Debug.Notification("Function: RunTrain called.")

    ;Move train to start
    Self.MoveTo(TrackPoints[0])

    ;Move player in to the train
    Game.GetPlayer().MoveTo(PlayerXEntryMarker)

    ;Start moving the train towards the first track point
    Self.TranslateToRef(TrackPoints[1], fMonorailSpeed)
EndFunction

Event OnTranslationComplete()
    Debug.Notification("OnTranslationComplete event called.")
    FindNextPoint()
EndEvent

Function FindNextPoint()
    Debug.Notification("Function: FindNextPoint called.")
    iTrackIndex += 1

    ;Check to see if there are any more track points. Otherwise, end of line
    If(iTrackIndex >= TrackPoints.Length)
	EndOfLine()
    Else
	;Move to the next track point
	Self.TranslateToRef(TrackPoints[iTrackIndex], fMonorailSpeed)
    EndIf
EndFunction

Function EndOfLine()
    Debug.Notification("Function: EndOfLine called.")
    iTrackIndex = 1
    Game.GetPlayer().MoveTo(PlayerXExitMarker)
EndFunction

 

Thanks for the reply,. I wish I could understand all that stuff. I've only just started modding so scripting is a bit beyond me at the moment.

 

What I tried to do to get my light source moving was took a npc (eyebot) and set a patrol for them. I was going to try attach a light to it but it wouldn't do the patrol outside my floating house mod. Maybe it the markers don't work in an LOD Worldspace. ( I staged it in the Commonwealth LOD for the skyline)

 

Anyway I haven't moved forward from that. Maybe I should learn scripting haha.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...