Set Direction Variable - GameMaker GML Visual
In this video we are learning how and when to use Game Maker Studio 2 GML Visual Block which is called:
Set Direction Variable
This block is part of the "Movement" group of drag and drop blocks.
It is used when you want to move some Object in very specific and precise direction.
So what differs this Block from similar Blocks we already explained earlier (like Set Direction Fixed or Set Direction Random) ?
Difference is that with this Block you have absolute control on Direction.
Meaning you can type literary any numeric value you want in "Direction" field.
It doesn't have to be in 45 degrees step like for Random or Fixed Direction where you had limited choices represented in arrow icons.
Here, you can use odd numbers and type increments in one, two, three, or as many degrees as you want.
Like 11, 27, 66, 99,...
Or use decimal values also.
Like 13.5, 29.88,...
Again,...
Don't forget to add some kind of speed to your Object, Direction only is not enough !
Direction is needed to define where do you want your Object to point and move - in which direction.
But to put it into motion you need to add some force on it, some speed to be precise.
So add "Set Speed" drag and drop block below "Set Direction Random".
Choose "Direction" from Type drop down menu, type some value in Speed field and that's it.
As always, be careful where and when you put this block in your code.
You will mostly add it to Create Event, but you can also change it later or put it into some If/Else condition statement.
You can use this block to:
- make enemies move in very specific and precise directions
- weapon shoots bullets in very specific and precise directions (angles)
- ...
#gamemaker #gamemakerstudio #gamemakerstudio2
#gamedev #gamedevelopment #gamedeveloper #gamedevelopmenttutorial
#gameengine #tutorial #youtubetutorial #youtubetutorials