Hello everyone
I am trying to execute OnReset() function in which is implemented reset position of some components
(reason is because those are physics objects in VR and when they stay in basic container before resetting, they spawn not at starting position defined by me but on 0,0,0 coordinates).
For some to me unknown reason, code written by me works if it is not in Reset function but don’t work
in Reset function.
This one works and result looks like this
for i in range(0, 10):
zel = app.findComponent("Válec_Z #" + str(i + 1))
zel_mat = zel.PositionMatrix
mod = app.findComponent("Válec_M #" + str(i + 1))
mod_mat = mod.PositionMatrix
cer = app.findComponent("Válec_Č #" + str(i + 1))
cer_mat = cer.PositionMatrix
for j in [zel_mat, cer_mat, mod_mat]:
j.setWPR(0, 0, 0)
vec_zel = vcVector.new(880.0, -1740.0 + 90 * i, 800.0)
vec_cer = vcVector.new(740.0, -1740.0 + 90 * i, 800.0)
vec_mod = vcVector.new(600.0, -1740.0 + 90 * i, 800.0)
zel_mat.P = vec_zel
cer_mat.P = vec_cer
mod_mat.P = vec_mod
zel.PositionMatrix = zel_mat
cer.PositionMatrix = cer_mat
mod.PositionMatrix = mod_mat
app.render()
sim.update()
And this code is the same but in OnReset() function and after resetting simulation it goes to this state which is starting situation.
def OnReset():
print("Hello")
for i in range(0,10):
zel = app.findComponent("Válec_Z #"+str(i+1))
zel_mat = zel.PositionMatrix
mod = app.findComponent("Válec_M #"+str(i+1))
mod_mat = mod.PositionMatrix
cer = app.findComponent("Válec_Č #"+str(i+1))
cer_mat = cer.PositionMatrix
for j in [zel_mat,cer_mat,mod_mat]:
j.setWPR(0,0,0)
vec_zel = vcVector.new(880.0,-1740.0+90*i,800.0)
vec_cer = vcVector.new(740.0,-1740.0+90*i,800.0)
vec_mod = vcVector.new(600.0,-1740.0+90*i,800.0)
zel_mat.P = vec_zel
cer_mat.P = vec_cer
mod_mat.P = vec_mod
zel.PositionMatrix = zel_mat
cer.PositionMatrix = cer_mat
mod.PositionMatrix = mod_mat
print (zel_mat.P.X,zel_mat.P.Y,zel_mat.P.Z)
getApplication().render()
getSimulation().update()
Is there any solution for my problem or is OnReset function special in something ?