playMaker

Author Topic: What does this line of code mean exactly?  (Read 2340 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
What does this line of code mean exactly?
« on: May 25, 2012, 07:45:24 PM »
I found this line of code in the Set Position event.

positionChange = space == Space.World ? go.transform.position : go.transform.localPosition;

I'm unfamiliar with this "==" and ":" and "?" syntax.  Would someone mind explaining this to me?
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: What does this line of code mean exactly?
« Reply #1 on: May 26, 2012, 01:47:42 AM »
It's a more compact way of saying:

if (space == Space.world)
{
   positionChange = go.transform.position;
}
else
{
   positionChange = go.transform.localPosition;
}