Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 05:03:59 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Controller objects?
Pages: [1]
Print
Author Topic: Controller objects?  (Read 1094 times)
SuperJonty
TIGBaby
*


View Profile
« on: July 11, 2017, 05:00:26 AM »

Hi everyone, fairly new to Gamemaker and whatnot - I've read various tutorials and I'm wondering what the best way to go about things is.

For example, moving the player. Is it better/more efficient to have a controller object that detects any/all inputs and a separate player object that checks the controller and takes action accordingly, or is it better to just have any detection and action in the object that's directly affected?
Logged
oahda
Level 10
*****



View Profile
« Reply #1 on: July 11, 2017, 05:41:51 AM »

The latter can be useful if you want to implement an AI or cutscene controller that you can use instead of the input controller sometimes.
Logged

Xorglord
Level 0
***



View Profile WWW
« Reply #2 on: July 11, 2017, 08:56:56 AM »

I think you should use a controller object. I haven't used Gamemaker much, so I can't give you specific feedback, but the way I do it (in Unity) works really well for me.

Input is received by my "controller object". Objects register with the controller object, saying that they will need to receive certain controls, and when the controller object detects these inputs, it passes them to the objects.

This works well for me because I have a number of times when I want to stop input from happening, or manually pass different inputs to characters (for example, in a cutscene). By doing it this way it makes it very easy to block / fake input without having to rewrite a lot of code.
Logged

muki
Level 2
**



View Profile
« Reply #3 on: July 17, 2017, 07:13:19 AM »

My visual brain loves control objects. It helps "solidify" code and routines and effects as objects you can drag in and out of your levels. That probably sounds weird.

At a glance you can look at a room, see the control objects and know it's running this and that.
Logged
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #4 on: July 17, 2017, 12:52:27 PM »

Controller objects make input remapping really easy, because you can just have an array of valid keycodes for an action. Plus, it's all in one place, which as other have pointed out, makes it conceptually easier for our stupid monkey brains.
Logged

Josh Bossie
Level 3
***


Fly Safe, Pup


View Profile WWW
« Reply #5 on: July 22, 2017, 10:41:58 PM »

My visual brain loves control objects. It helps "solidify" code and routines and effects as objects you can drag in and out of your levels. That probably sounds weird.

At a glance you can look at a room, see the control objects and know it's running this and that.

Yeah, absolutely agreed. I think this is especially important for a language like GMC which lacks classes and other ways to keep code, uh, 'solid'. There's gotta be a better term for it, but I also use it and whatever, it works!
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic