How to get creature in world?

Hi, i wanna know how can i get the pointer to a creature that it is already spawned in the World.
I have the creature Guid, from a query “Select guid from creature where id = myentry”, then i write:

if (Unit* unit = sObjectAccessor->FindUnit(myguid)) if (Creature* creature = unit->ToCreature())

That its correct?
Thanks in advance.

Do you have some other worldobject on the same map that you have access to?
For example if you are trying to do this stuff when a player does something and the creature should be near the player (on same map, probably in sight),

you have access to player (a worldobject).

Then you can do this:

Creature* creature = sObjectAccessor::GetCreature(*player, MAKE_NEW_GUID(dbguid, entry, HIGHGUID_UNIT));
You can get dbguid and entry from the database or w/e
Im hoping you are not in an instance /emoticons/default_smile.png

Hey, no i dont have a worldobject but I will try using one, thanks for reply!

If you cant get it to work, tell more about your situation.

Things like what hook do you use (which Script class and which function) and so on.

Sharing the script wouldnt be bad either.