Jump to content

Hiding entities and physics


AggrorJorn
 Share

Recommended Posts

I have a hitbox on the players location. When the player dies it loads in a lowpoly shape (default script of the FPS player script.) However the loaded shape, is now intersecting with the hitbox, which causes the lowpoly shape to start twitching around.

 

To resolve this issue I first thought that simply hiding the hitbox entity would solve the problem, since hidden entities no longer have physics interaction. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entityhide-r181

 

 

However this didn't help at all. The loaded shape was stil flipping around like it was intersecting with the hitbox. Releasing the hitbox resolves the problem, but that is not what I want to do, since I want to restore the hitbox.

 

--This script works, since the hitbox is released.
hitbox:Release()
shape: Load()

--This script doesn't work, even though the hitbox doesn't have any collision.
hitbox:Hide()
shape: Load()

 

Other things I tried:

  • Setting the collision type of the hitbox to NONE.

 

 

Things I haven't tried yet:

  • Loading the lowpoly shape 1 frame later after hiding the hitbox.
  • Repositioning the hitbox to a different location.

 

Any thought on what this could be?

Link to comment
Share on other sites

it loads in a lowpoly shape (default script of the FPS player script.) However the loaded shape, is now intersecting with the hitbox, which causes the lowpoly shape to start twitching around.

Any loaded model with no physics will not interact with physic shapes.

You chouls try to make a prefab with no collision setting in the editor and no collision volumes and try loading that prefab instead, or are you already loading it as prefab ?

Stop toying and make games

Link to comment
Share on other sites

The FPS script loads a lowpoly shape to a pivot (not a model/prefab) that is used as corpse.

self.corpse = Pivot:Create()
local shape = Shape:Load("Models/Characters/Generic/corpse.phy")--this shape is made from a low-poly CSG sphere, so it will roll around a bit but come to a stop quickly
self.corpse:SetShape(shape)
self.corpse:SetCollisionType(Collision.Prop)

 

The loaded shape (corpse) behaves as intended, it is the hitbox that causes the issue. It should not cause collisions or collision twitching since it is hidden (and/or) collisiontype gets set to none.

Link to comment
Share on other sites

It should not cause collisions or collision twitching since it is hidden (and/or) collisiontype gets set to none.

 

Or this is a bug, or collision should not be called in a pivot, or collisionType can't work with Shape:Load(ZZZ.phy) ?

 

self.corpse:SetShape(shape)

 

Or i'm not sure the pivot to be aware of the attached shape ?

I just find very strange this way of working by code.

Why not just load a model with physics and save it as prefab or do you need some things to be dynamic , in that case prefab is not the solution ?

Stop toying and make games

Link to comment
Share on other sites

This is not something I have written, as it is part of the deafult FPSscript. There is no model/prefab being loaded. The corpse is just a shape (.phy) which is set to the pivot. The pivot is placed at the position of the player.

 

By the looks of it, hiding an entity, does not disable the physics of the object (right away), because other objects are interfering with it.

 

I have to try out if this is actually the case in other scenarios.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...