You are viewing our Forum Archives. To view or take place in current topics click here.
[UNITY3D] How would i call a function once in an Update?
Posted:

[UNITY3D] How would i call a function once in an Update?Posted:

PostMalone
  • TTG Contender
Status: Offline
Joined: Mar 25, 20168Year Member
Posts: 3,648
Reputation Power: 424
Status: Offline
Joined: Mar 25, 20168Year Member
Posts: 3,648
Reputation Power: 424
I know a function Update() is called every second but im trying to figure out how i can only call a function once. Ive tried using a boolean and i cant see to get it to work. I've also tried a coroutine and i cant get that to work either. Any help is appreciated, im using JavaScript to do this.

Heres an example of my code
[ Register or Signin to view external links. ]


Last edited by PostMalone ; edited 1 time in total
#2. Posted:
speed
  • V5 Launch
Status: Offline
Joined: Jun 11, 200914Year Member
Posts: 9,897
Reputation Power: 3160
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Status: Offline
Joined: Jun 11, 200914Year Member
Posts: 9,897
Reputation Power: 3160
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Post examples of the code you're using.
#3. Posted:
BPM
  • Rated Awesome
Status: Offline
Joined: Sep 12, 201013Year Member
Posts: 7,232
Reputation Power: 1137
Status: Offline
Joined: Sep 12, 201013Year Member
Posts: 7,232
Reputation Power: 1137
Isn't that what

Start(){
...
}

is for? Haven't used Unity in a bit.
#4. Posted:
PostMalone
  • Winter 2020
Status: Offline
Joined: Mar 25, 20168Year Member
Posts: 3,648
Reputation Power: 424
Status: Offline
Joined: Mar 25, 20168Year Member
Posts: 3,648
Reputation Power: 424
BPM wrote Isn't that what

Start(){
...
}

is for? Haven't used Unity in a bit.



Start() only runs when the script is executed/starts. Im checking for a variable to change which is why im relying on an update function to check for that. Once it changes i call another function, but i only need to call that function once, but instead its called 30 times a second every second because the variable meets the requirement
#5. Posted:
PostMalone
  • Winter 2020
Status: Offline
Joined: Mar 25, 20168Year Member
Posts: 3,648
Reputation Power: 424
Status: Offline
Joined: Mar 25, 20168Year Member
Posts: 3,648
Reputation Power: 424
speed wrote Post examples of the code you're using.


its put in there now
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.