Object on motion path question


(Jonathan Hart) #1

Hi,

Wondering if it’s possible to have an object on a winding motion path and have it move forward and back to various points on that path depending upon if the user clicks certain click targets?


(Jonathan Deutsch) #2

This is possible - motion paths can be made as separate joined animations, and then you can use timeline playback controls of continuing or continuing in reverse to move along the path with pause points as timeline actions. Here’s a basic example:

MotionPathSegments.hype.zip (19.6 KB)


(Jonathan Hart) #3

Can anything be done to create a more non-linear movement- i.e from point 3 to 1? What I’m looking to do is move a vehicle object back and forth along a path depending on if a point is ‘active’. I’ve included a hype file as an example of where I’ve got to.test.zip (278.2 KB)


(Jonathan Deutsch) #4

There might be a creative way to do this with timelines, but a little bit of Javascript is probably the best way. Instead of making the timeline actions pause the timeline, I would have those run javascript which would conditionally pause or not. Each would be designated with some identifier to know whether to pause.

A click to go to a specific spot would look something like:

	window.pauseIdentifier = "stopPointOne";
	var pauseTime = 0.0;
	var currentTime = hypeDocument.currentTimeInTimelineNamed('Main Timeline');
	var playInReverse = currentTime > pauseTime;
	hypeDocument.continueTimelineNamed('Main Timeline', (playInReverse ? hypeDocument.kDirectionReverse : hypeDocument.kDirectionForward));

And then the timeline action code would check against the pauseIdentifier:

	if(window.pauseIdentifier == "stopPointOne") {
		hypeDocument.pauseTimelineNamed('Main Timeline');
	}

Here’s it working in action:

MotionPathSegments-v2.hype.zip (21.8 KB)


(Jonathan Hart) #5

That’s very clever. Will be invaluable- thank you for your time.