Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
void OnStart() void OnEnter()
4WalledKid Offline
Member

Posts: 107
Threads: 23
Joined: Oct 2012
Reputation: 1
#1
Question  void OnStart() void OnEnter()

Can someone explain me the differences between the void OnStart() and the void OnEnter()? I know that void OnStart() is called when the player start a map for the first time. But what is the void OnEnter()? Where is the player entering? Thanks.

[Image: 4walledkidbanner_zps1514b7f6.png]
(This post was last modified: 10-17-2012, 05:09 PM by 4WalledKid.)
10-13-2012, 11:48 PM
Website Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: void OnStart() void OnEnter()

OnStart is one time only as you described, onEnter happens every time the player enters/re-enters the map (i.e. a hub scenario)

I rate it 3 memes.
10-13-2012, 11:51 PM
Find
4WalledKid Offline
Member

Posts: 107
Threads: 23
Joined: Oct 2012
Reputation: 1
#3
RE: void OnStart() void OnEnter()

(10-13-2012, 11:51 PM)andyrockin123 Wrote: OnStart is one time only as you described, onEnter happens every time the player enters/re-enters the map (i.e. a hub scenario)
So let's say that I want that when the player enters the map for the first time something happen. Then he leaves. And now he re-entered the map. How do I control in which time the player enters the map, something will happen? Thanks for your reply.

[Image: 4walledkidbanner_zps1514b7f6.png]
10-14-2012, 12:27 AM
Website Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: void OnStart() void OnEnter()

You can use global variables with the "OnEnter" function to control when an event happens (i.e. perhaps the player gets another item from another map, or it's triggered just by how many times the player enters altogeter).

Here's a loop that adds a variable, and after the variable reaches x amount, it will trigger whatever script:

Spoiler below!

void OnEnter()
{
AddGlobalVarInt("var", 1);


if(GetGlobalVarInt("var") = 3)
{
///do stuff here
}
}


On the third time the player enters the map, it will activate the "do stuff here" part; this can be pretty much anything you'd want - setting up a callback, playing a sound, triggering a spooky event - anything.

Hope that helped!

I rate it 3 memes.
10-14-2012, 12:38 AM
Find
4WalledKid Offline
Member

Posts: 107
Threads: 23
Joined: Oct 2012
Reputation: 1
#5
RE: void OnStart() void OnEnter()

This is a little hard to understand isn't it?

[Image: 4walledkidbanner_zps1514b7f6.png]
10-14-2012, 01:50 AM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#6
RE: void OnStart() void OnEnter()

No, it isn't Wink

Let's say you have a map where you have a door and a key. The key opens the door. If the player leaves and everything was in OnStart(), when the player returns that key will be useless, because it was only usable the first time you went into the map. OnEnter () is more for "bug fixing".

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-14-2012, 09:31 AM
Find
4WalledKid Offline
Member

Posts: 107
Threads: 23
Joined: Oct 2012
Reputation: 1
#7
RE: void OnStart() void OnEnter()

(10-14-2012, 09:31 AM)The chaser Wrote: No, it isn't Wink

Let's say you have a map where you have a door and a key. The key opens the door. If the player leaves and everything was in OnStart(), when the player returns that key will be useless, because it was only usable the first time you went into the map. OnEnter () is more for "bug fixing".
So OnEnter() will call the functions every time the player enters the map until I use some "if" statement?

[Image: 4walledkidbanner_zps1514b7f6.png]
10-14-2012, 02:14 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#8
RE: void OnStart() void OnEnter()

It isn't necessary to use an "if". For example, a hub. You want that when you enter a map a quiet music sounds, like in the main game.

If you put in OnStart(), the music will only sound when you enter in that map, if you leave and enter another time the music won't sound.

If you use OnEnter(), the music will sound every single time you enter. If you leave and enter another time, the music will sound.

If you want to make more complicated things, go forward. Use "if"s if you need them.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-14-2012, 02:54 PM
Find
MyRedNeptune Offline
Senior Member

Posts: 553
Threads: 3
Joined: May 2012
Reputation: 33
#9
RE: void OnStart() void OnEnter()

(10-14-2012, 02:14 PM)4WalledKid Wrote:
(10-14-2012, 09:31 AM)The chaser Wrote: No, it isn't Wink

Let's say you have a map where you have a door and a key. The key opens the door. If the player leaves and everything was in OnStart(), when the player returns that key will be useless, because it was only usable the first time you went into the map. OnEnter () is more for "bug fixing".
So OnEnter() will call the functions every time the player enters the map until I use some "if" statement?
To explain Andyrockin's script: A variable is just a number that you can change. In the script, each time the "OnEnter" function is called, we increase the variable by 1. Then we check whether or not the variable is equal to 3. If it is, the game moves on to do whatever we specified inside the { } brackets.

^(;,;)^
10-14-2012, 03:12 PM
Find
4WalledKid Offline
Member

Posts: 107
Threads: 23
Joined: Oct 2012
Reputation: 1
#10
RE: void OnStart() void OnEnter()

Oooh ok ok, and what was the global variable thing? And the item thing too.

[Image: 4walledkidbanner_zps1514b7f6.png]
10-14-2012, 05:56 PM
Website Find




Users browsing this thread: 1 Guest(s)