Skip to content

Change body shape and(or) it's properties #324

Answered by RossNordby
wrenge asked this question in Q&A
Discussion options

You must be logged in to vote

Almost! GetShape returns a reference to the shape. Since the shape itself is a value type, assigning to a non-ref variable just copies it, so it's no longer a reference to the original memory.

If you changed it to:

ref var shape = ref Sim.Shapes.GetShape<Box>(originalShape.Index);

then it would be a memory reference.

GetDescription works differently; it builds a BodyDescription for you, but modifying it will not modify the original because it's just a copy of the data again. Because there is no place in the library where a BodyDescription actually sits around, it can't return a ref to it. You can use ApplyDescription to set all of a body's properties to match the description.

You can als…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wrenge
Comment options

Answer selected by wrenge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants