Program1031.comTM
Game Programming Help for Beginners!
Home Questions and Answers Physical and Digital Books

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 Maker: Studio
Help, References, and Tutorials
RPG Maker Fes
Help, References, and Tutorials
smileBASIC
Help, References, and Tutorials

Physical and Digital Books
Search Physical and Digital Books at Program1031.com

Home Questions and Answers Email Newsletter
Watch our YouTube channel
Content and Design © 2012-2025 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!