Program1031.comTM
Game Programming Help for Beginners!
Home Need Help? Start here!
Questions and Answers
Get Exclusive Stuff!
Email Newsletter

Question:
How do I change a variable of other objects in Game Maker from a different object?


Answer:

Usually, you'll want to change an objects variable from that same object during the game. But sometimes you might want to change another object's variable from a different object. Here's how you do it:

Let's say we have two objects: objPlayer and objScore. Let's say objScore has a variable theScore. And let's also say that when objPlayer collides with something, we want to change the score variable in objScore.

In the collision event of the objPlayer with the other object, execute this code:
objScore.theScore += 1;

This code will add 1 to the score when the objPlayer collides with something! Just put the objects name, a period, then the variable name. Epic!

Page updated: March 23rd, 2015 @ 6:21 AM Eastern Time

Game Making Tutorials
Find tutorials about your favorite game creation software! Use the navigation below!

Game Maker: Studio
Help, References, and Tutorials
RPG Maker Fes
Help, References, and Tutorials
smileBASIC
Help, References, and Tutorials

Download Books
Search Downloadable Books from Program1031.com

Home Questions and Answers Email Newsletter
Watch our YouTube channel Read our Twitter feed
Content and Design © 2012-2023 Program1031.com. All Rights Reserved. | Privacy Policy | Terms of Service
All Copyrights and Trademarks of mentioned products are copyrights and trademarks of their respective owners.

As an Amazon Associate and ChristianBook.com Affiliate, Breakthrough Gaming LLC earns a commission on qualifying purchases from Amazon.com and ChristianBook.com through our website. Thank you for your purchases!

Our other websites: