#How do I properly add physic to an entity at runtime ?

1 messages · Page 1 of 1 (latest)

fiery pagoda
#

Hello,
To give you some context : I want the player to throw a sphere (aim mode etc). So at the beginning I instanciate it as a child of an anchor of the player. And then, when the player want to throw the sphere I want to add the additional components to integrate it to the physic (dynamic with linear interpolation) and give it some velocity. Of course if it can be done otherwise it's fine too. But trying to disable the simulation by removing the world index was a failure on my side.
How do you do that properly?
Thanks !

noble atlas
#

But trying to disable the simulation by removing the world index was a failure on my side.
what went wrong with this because i'd say it's not too uncommon a way to handle it

fiery pagoda
#

I just checked again and like I remembered, modifying the local transform won't do anything, and the parent origin was taken into account even when touching nothing in the editor (just letting the transforms system do their things).

#

Anyway if you say that's the common way to do so I'll check more, thanks !

noble atlas
#

i'm not really sure what removing physic world index and local transform have in common

fiery pagoda
#

Yeah same here, I'll try with a reduced usecase after eating/sleeping I guess !

#

Okay so just to tell, if I don't ask for a smoothing, then the transform is right. So it's probably because of the 2 Graphical components.

noble atlas
#

ah yeah that makes sense

fiery pagoda
#

Well in the end it looks like I can manually add the smoothing with no real troubles.
So removing the indexworld is ok.
And in fact, adding the components is far less complex than I though with the code I saw :
https://forum.unity.com/threads/create-a-runtime-entity-with-physic-body.1479345/

I fell like I'll use both of the approach because I also need an authoring which doesn't allow to tweak the physic settings of the entity.
Well that's it for this ^^
Thanks