Resources > Coding
[Request / Listing] I need some easy help...
(1/1)
dodgefreak:
For the game I'm making, Zelda Universe, I need some coding.
First, How do I make Link enter a house?
How do I make NPCs walk around randomly, like Animal Crossing characters?
I need step by step instructions, and I'm using GameMaker 6.
Thanks in advance.
Atom:
Going to different rooms/go inside houses
You could make an object called obj_gotoroom.
As you need step by step instructions I guess you wish the easiest way. So best is to make a new object for each room you wish to go to.
In that object make a collision event with obj_link with the following code.(adapt with the correct names to get it working)
--- Code: ---global.createplayerx=xpostition of where you wish link to appear in the room (in numbers)
global.createplayery=yposition of where you wish link to appear in the room (in numbers)
room_goto(roomname)
--- End code ---
In the create event of the room where you wish to go( in this case the house)
--- Code: ---Instance_create(global.createplayerx,global.createplayery,obj_link)
--- End code ---
therabidwombat:
Assuming this is in GM, you can do the movement with alarms. Set the alarm to a random time, then when it executes, generate a random number from 0-3 (or 1-4 if that's easier for you). Make each possibility a direction (0 is up, 1 is right, 2 is down, 3 is left, for example). Make the NPC move in that direction, and set a second alarm to make the NPC stop. When the second alarm goes off, stop the NPC, and reset the first alarm.
Piers:
Or (Expanding on TRW post) you could put in (If you want the enemy to move in any direction)
direction = random(360)
Navigation
[0] Message Index
Go to full version