Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  NullReferenceException in ObiRopeCursor (build)
#2
Hi!

Cursors initialize their reference to the rope component in OnEnable(). Actors -such as ropes- are initialized in OnEnable() too, and get their OnBlueprintLoaded called.

Since the order in which Unity calls events for different components is undefined by default (the specific order might change between editor/runtime, and even between different runs of the same scene) chances are the cursor is attempting to change the length of the rope before its own OnEnable() event has been called, so the reference to the rope is still null.

A solution is to change the length of the rope in Start, instead of OnBlueprintLoaded. Start() is guaranteed to be called after OnEnable().

let me know if you need further help,

kind regards
Reply


Messages In This Thread
RE: NullReferenceException in ObiRopeCursor (build) - by josemendez - 11-05-2023, 03:08 PM