Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

When I remove that part I get this error. Phase is not defined.

(TS_Dyn_WitchOrbHover is what I've put this stuff into.)


(2 edits)

I missed the first line(s) while copying, sorry. This should be fixed:

// This likely doesn't look great on moving Events!
const phase = (x, y) => (x * 147 + y * 15) % 11 / 5.5 * Math.PI;
TS_Dynamic_Characters.parameters.modifierDefinitions.push(new TS_Dynamic_Characters.ModifierDefinition({
	name: 'bob-and-sway',
	bushDepth: 25, // This (by default) also turns on bush display for tile Events.
	anchorY: 50, // To rotate around the (vertical) centre, not the bottom.

	// Note that using a custom function for any "offset" will turn off offset rounding by default!:

	yOffsetVertical: function (t, { x, y }) {
		// The second argument above is a `Game_CharacterBase` instance, which (among many more) has `x` and `y` properties.
		// `this`, here, is the `ModifierDefinition` instance.
		return -3 * t * Math.sin(phase(x, y) + Graphics.frameCount / 20);
	},

	// You can also write this more concisely, but without `this`:
	angle: (t, { x, y }) => 5 * t * Math.sin(phase(x, y) + Graphics.frameCount / 15),
}));

The phase formula is totally arbitrary, I just wrote something to make it different based on which tile the event sits on. You may want to use a formula that changes much more slowly in space (and also use { _realX: x, _realY: y } instead of { x, y } to get fractional numbers, but that can still look wrong on a looping map sometimes).

(+1)

That worked, thank you! I'll play with the formula from here to achieve the effect I'm going for.