Proper way to make immediate mode follow a gameobject

Avatar
  • updated
  • Answered

Is there a proper way to draw stuff in immediate mode while following a gameobject or am I better off just using the components?

Also, how would you draw a polygon in X, Z instead of X, Y using immediate mode.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

Immediate mode is intended to be updated every frame, but if you want it to follow an object or a transform, the easiest way is to set:

Draw.Matrix = transform.localToWorldMatrix;
// draws in local space here
Draw.ResetMatrix(); // to make sure other immediate mode drawing doesn't follow the object

as for drawing in XZ, you would set a new rotation of the object using the same matrix system, since polygons are always flat in their local XY space

Avatar
Louis
Quote from Freya Holmér

Immediate mode is intended to be updated every frame, but if you want it to follow an object or a transform, the easiest way is to set:

Draw.Matrix = transform.localToWorldMatrix;
// draws in local space here
Draw.ResetMatrix(); // to make sure other immediate mode drawing doesn't follow the object

as for drawing in XZ, you would set a new rotation of the object using the same matrix system, since polygons are always flat in their local XY space

Thank you so much for the super quick reply, it's appreciated!

Avatar
Freya Holmér creator
  • Answer
  • Answered

Immediate mode is intended to be updated every frame, but if you want it to follow an object or a transform, the easiest way is to set:

Draw.Matrix = transform.localToWorldMatrix;
// draws in local space here
Draw.ResetMatrix(); // to make sure other immediate mode drawing doesn't follow the object

as for drawing in XZ, you would set a new rotation of the object using the same matrix system, since polygons are always flat in their local XY space