Jump to content

Chaining TranslateTo without gaps


Recommended Posts

Hi guys,

 

I'm trying to chain a series of TranslateToRef by looping a state to step through an array of destinations, but I'm getting very noticeable gaps between completed translation and the next translation. CK wiki recommends using OnTranslationAlmostComplete() to avoid execution delay, but the gaps are still there.

 

I'm just wondering if anyone has been able to do this without gaps in movement.

 

Thanks! :smile:

Link to comment
Share on other sites

OnTranslationAlmostComplete works for me. Translations work better for activators and npc's, but npc's ignore rotation on x and y axis, also you can try using keyframed motion with Ref.SetMotionType(Ref.Motion_Keyframed) before starting the translation.

 

Edit: Additionally, you might want to try calling StopTranslation before the next call to TranslateTo.

Edited by DieFeM
Link to comment
Share on other sites

Thank you very much for replying, DieFeM!

 

Well, I am using an activator as an attach ref host (rotatehelperfree as a dummy host), and the translation itself is smooth, but it's when moving to the next step from the (almost) complete translation I see gap in motion (when it loops back to the top of "Loop" state).

 

I've tried the motion type keyframed, and also stopping translation before looping to top as you suggested, but those made no difference in my case (I think the helper activators are keyframed by default). The "gap" is probably somewhere around 0.2 second or so.

Scriptname TestSubject:ChainedTranslate extends ObjectReference

ObjectReference[] Property Dest Auto Const

Float Property MoveSpeed = 100.00 Auto Const

int Pos = 0


auto state StartUp

	Event OnActivate(ObjectReference akActionRef)
		Self.SetMotionType(Self.Motion_Keyframed)
		GotoState("Loop")
	EndEvent
	
EndState

state Loop

	Event OnBeginState(string asOldState)
			Self.TranslateToRef(Dest[Pos], MoveSpeed)
			Pos += 1
	EndEvent
	
	Event OnTranslationAlmostComplete()
	
		If Pos < Dest.length
			Self.StopTranslation()
			GotoState("Loop")
		Else
			GotoState("End")
		EndIf
		
	EndEvent

EndState

state End

EndState

I have the default speed at 100, but I am testing at much faster speed (500 - 700) because the goal is to create a train car (as a platform) which can navigate curved tunnel parts. The gap is not as noticeable at very low speed like 100, but when it's faster I can definitely tell the gap is there. :confused:

 

If you see anything wrong with what I am doing, would you please let me know? Thanks again!

Link to comment
Share on other sites

The only difference I see from what I usually do is the use of states, maybe GoToState creates some kind of delay. I would give a try to something in the empty state:

Scriptname TestSubject:ChainedTranslate extends ObjectReference

ObjectReference[] Property Dest Auto Const
Float Property MoveSpeed = 100.00 Auto Const

Int Pos = 0
Bool Translating = False


Event OnActivate(ObjectReference akActionRef)
	If !Translating
		SetMotionType(Motion_Keyframed)
		Translate()
		Translating = True
	Else
		StopTranslation()
		Translating = False
	EndIf
EndEvent

Event OnTranslationAlmostComplete()
	If Pos < Dest.Length
		Pos += 1
		Translate()
	EndIf
EndEvent

Function Translate()
	If Translating
		StopTranslation()
	EndIf
	TranslateToRef(Dest[Pos], MoveSpeed)
EndFunction
Edited by DieFeM
Link to comment
Share on other sites

I've tried your script, but at the speed I'm testing (500), the gap seems to be actually the same as my script with states. Would you mind trying and see how higher speed would work on your side? I do find that at lower speed like 100, it's less noticeable here as well.

 

Thanks again. :smile:

Link to comment
Share on other sites

Thank you DieFeM for mentioning the distance maybe being the factor. I said about my goal being a train, but I was testing the translation itself like this :

 

 

 

34555-1585654574-1272475521.png

 

 

 

...so this was the experiment I saw gaps in movement with. The xmarkerheadings are the destinations, and they are packed very tight in this experiment.

 

After reading your post, I went ahead and made the actual train movement :

 

 

 

34555-1585654575-1797598607.png

 

 

 

...and at these moving distances, the gaps didn't seem to happen in obvious way. I've switched back to my original script, and it works fine for me so far (so it seems the state does not cause delay). So, as you suggested, it seems that the distance between destinations (or time between each translations being executed?) would ease the transitions. At move speed of 500, it looked like there's no issues to me. :thumbsup:

 

(It could also be the perspective affecting the perception - I was watching Tractor01 from side in the first experiment, but with a train, I was actually inside the moving platform.)

 

Thanks again for your help with this! :smile:

Link to comment
Share on other sites

I'm glad to help, I also did something similar, and you'll find out that is almost impossible to fit the train in ramps with that "much" inclination, the train is simply too long for a train track with so much inclination.

Link to comment
Share on other sites

Yeah, I was testing with the monorail car, and outer shell did clip out of the tunnel, lol. :laugh: From inside, though, I thought it looked mostly fine, because the interior floor seemed to be high enough (I think the train car can be pushed up in unrealistic way, ignoring the ceiling railing, too, so long as the player won't see it). Maybe creating a shorter trolley style car would be necessary if I want to do this for real.

 

I think the biggest problem is the Havok, since the moving platform won't add any momentum to the actors on it. Jumping straight up would result in actors not moving along with the platform. Also, when moving up/down the slopes, the train mesh seemed to micro nudge the player, making the camera jittery in places (I can probably get away with creating metallic noises as sound effects to give an impression that train is vibrating, though).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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