Jump to content
GamaPony

Problem with Physics Shapes on moving objects.

Recommended Posts

Hi!

I'm currently working on an RV vehicle that the user can drive around.
The idea was for them to be able to park it up, open the side door and enter the interior while they're not driving.

I've noticed the Physics Shape turns from PRIM to CONVEX while it's moving (as to be expected).
But once it's no longer physical or moving, it doesn't return to it's PRIM physics shape.


In an attempt to fix this I've scripted the RV to switch from CONVEX to PRIM when the side door is opened, however the Physics Shape doesn't seem to update.
Once the RV is right-clicked it's Physics Shape will suddenly update and allow the avatar inside.

So it seems objects that turn physical or move are set to convex, but afterwards it's impossible to change their physics shape with scripts until the object is next edited.
Is this a bug? And has anyone found a work around?

Thanks for any help!

Share this post


Link to post
Share on other sites

Maybe a silly question, but couldn't you just create a physics model that is designed so that you can walk into it the way that you would walk into a house or any other structure?  It seems awkward to keep switching the physics shape type.

Share this post


Link to post
Share on other sites

dunno if this would help but, mebbe try using a SLPPF call and change some small thing to force an update?

 

Share this post


Link to post
Share on other sites

Hmm I think I did have this same problem. Otherwise all work but this annoying change to convex, got booted out of me mesh boat.:$

and clicking fixed it .O.o

I found out that in my case reason was how I imported mesh shape to SL

I made a cube in blender exported it to dae. and used that as collision shape to import me mesh boat to SL

also I imported separately me real collision shape for me boat to SL . That fixed it for me.:)

Edited by FalsusMendax

Share this post


Link to post
Share on other sites

I should elaborate a little.

As Rolig Loon and FalsusMendax mentioned physics models I should point out that the RV is mesh, and has been uploaded with a proper hollow physics/collider shape allowing avatars inside it. This is the physics shape the object uses when it's Physics are set to "Prim".

And as Xiija mentioned SLPPF, that's exactly what I'm doing but isn't/wasn't working properly.

 

It would seem that moving objects (Set to "Physical", vehicles or moving links with PRIM_POS) sets the object's Physics from "Prim" (our physics shape) back to "Convex".
This is normal for physics systems as hollow mesh collisions can be buggy.

The odd behaviour is that setting the Physics back to "Prim" via scripts once the object is no longer physical or moving doesn't seem to work.
Doing so in the Edit window works fine. And if done via scripts, the object remains as "Convex", but right-clicking the object afterwards seems to update the object's settings and the Physics=Prim change from the script finally takes place.

 

One fix I've found for this is using llSleep(1) to give your object a second to realise it's no longer moving/physical, THEN setting it to Prim via the script.

This is annoying as opening the RV door counts as object movement, so I can't simply open the door with SLPPF.

  1. I have to set the door to it's open position via llSetLinkPrimitiveParamsFast() 
  2. Then llSleep(1) to give it time to realise the door has finished it's movement
  3. Then another llSetLinkPrimitiveParamsFast() to set the physics shape back to Prim.

 

I'm not entirely sure if this is just a script latency issue, or an actual bug with physical objects.
The fact that setting the Physics shape to "Prim" via scripts doesn't work, but will apply once the object is selected would lean towards it being a bug though.
Hope this may help someone else with this issue in the future.

  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, GamaPony said:

One fix I've found for this is using llSleep(1) to give your object a second to realise it's no longer moving/physical, THEN setting it to Prim via the script.

I suspect that's why Xiija suggested that you should

On 7/19/2018 at 10:46 AM, Xiija said:

try using a SLPPF call and change some small thing to force an update?

The point of that idea is that sometimes the servers will not recognize that the status of an object has changed unless they are startled by having to make some other small change.  When you suspect that the servers are not paying attention, you can jog them by, say, forcing a change in the alpha or color of a child prim, or adding a bit of transparent hover text. You may have accomplished the same thing by adding a bit of llSleep, simply because the servers do a little reality check when an inactive script wakes up.

Share this post


Link to post
Share on other sites

llSleep(1); is a great way to fix little things being passed over by the server, and get a sort of "refresh" going with a script. However, I cannot, in good conscience, allow it to pass without comment that you should be careful who you tell about this function. It's actually considered better coding practice to replace something simple and functional like llSleep(1); with timer events, and if you already have a timer event in your script, you'll need to find a way to use one of the hacks posted on the forum for tricking the script into not realizing it's really doing the same thing as using two timer events. This may complicate things, and make scripting far more difficult for you to learn, but it's the recommended method. llSleep() is a function fraught with many dangers, as any experienced scripter can tell you, and it's been known to plague scripters far into their careers, ruining good coding practices, and spreading like wildfire in a destructive swath of little momentary pauses.

Sorry to bring up such things, but I feel it is my duty as a responsible member of the forums to let people know the dangers of llSleep(), as it was so forcefully made clear to me how bad it is to use it for anything (shame, fear and guilt are powerful tools when it comes to educating me, I suppose). I can't really recommend llSleep() to anyone for any purpose, unless, failing every other function on the wiki, one is simply compelled to use it out of sheer necessity, and I simply can't believe it's being recommended by such an otherwise responsible member of these forums.

Just kidding. There's nothing wrong with llSleep(). I was just going to thank you for posting what you discovered when you solved your issues, and contributing to the knowledge pool by doing so, and I saw the llSleep thing, and had to have a giggle at a little "running gag" of ours... 

By the way, thank you so much for posting what you discovered when you solved your issue. I like to think that doing so is part of good forum posting practice, and it's always to be encouraged. ^-^

Edited by PheebyKatz
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...