It makes sense to me, too.
Hopefully I will fix the teleporting problem at some point and some of this becomes simpler. Though in your multiple game session approach, some of this was for the best anyway.
It makes sense to me, too.
Hopefully I will fix the teleporting problem at some point and some of this becomes simpler. Though in your multiple game session approach, some of this was for the best anyway.
I experience the same issue. All I did (previously) was set the physical body position. This would work for in-range zones. When I tried to warp to a zone outside the range, the body would get warped but the spatial would remain at the source location (and thus also the camera, which I have bound to the player spatial).
I can work around it by changing the ZONE_RADIUS
to simply include all of the map.
I tried looking into the ZoneManager
to see if there was a way I could decipher how to fix it, but alas, to no avail. I hope you manage to get time to implement a solution for it
Cheers.
I think you can try my trickery with reassign the client id to ethereal. Maybe you also have first remove the Position and re-add it one frame later and reassigne the client id.
Hmm[quote=“ia97lies, post:23, topic:38743, full:true”]
I think you can try my trickery with reassign the client id to ethereal. Maybe you also have first remove the Position and re-add it one frame later and reassigne the client id.
[/quote]
I’m not really keen on that, since my game is a persistent one. So I’d have to do all sorts of stuff to re-assign whatever the player then has stored of information (score, inventory whatnot).
You can reassigne the very same thing (entity id), I do that! Maybe not even need to remove/add position, any way remove the position and add a new one does not feel wrong to me.
I guess it makes sense if you are already dealing with session information. But mine is game logic - it makes little sense to have an AbstractGameSystem
that (somehow, I cannot figure that part out) calls to HostedConnection
and then to EtheralHost
:
HostedConnection hc = getSystem(AccountHostedService.class).getHostedConnection(e.getId());
if (hc != null) {
getSystem(EtherealHost.class).setConnectionObject(getSystem(AccountHostedService.class).getHostedConnection(e.getId()), e.getId().getId(), targetLocation);
}
AccountHostedService
is not a System
, but a Service
, so is kept on the Server object - which I cannot figure out how to access. And it also seems wrong to accces it from game logic.
Ok, true I only look at it from my perspective you are right for game logic it feels wrong to deal with game sessions.
Access from where?
From an AbstractGameSystem > Update:
@Override
public void update(SimTime tpf) {
time = tpf;
//warpTouchEntities.applyChanges();
warpers.update();
if (warpToEntities.applyChanges()) {
for (Entity e : warpToEntities) {
SimpleBody body = simplePhysics.getBody(e.getId());
if (body != null) {
BodyPosition pos = e.get(BodyPosition.class);
Vec3d targetLocation = ed.getComponent(e.getId(), WarpTo.class).getTargetLocation();
Vector2 originalLocation = body.getTransform().getTranslation();
Vec3d origLocationVec3d = new Vec3d(originalLocation.x, originalLocation.y, 1);
//Right now, this is how I translate the ship (and everything else) to the new location - and it works as long as the `ZONE_RADIUS` is big enough for the `targetlocation` to be included in the radius.
body.getTransform().setTranslation(targetLocation.x, targetLocation.y);
//This is how it 'could also be done?'
/*
HostedConnection hc = getSystem(AccountHostedService.class).getHostedConnection(e.getId());
if (hc != null) {
getSystem(EtherealHost.class).setConnectionObject(getSystem(AccountHostedService.class).getHostedConnection(e.getId()), e.getId().getId(), targetLocation);
}
*/
//getStateListener(hc).setSelf(selfId, initialPosition);
GameEntities.createWarpEffect(origLocationVec3d, ed);
GameEntities.createWarpEffect(targetLocation, ed);
ed.removeComponent(e.getId(), WarpTo.class);
}
else{
throw new RuntimeException("Entity has a body position, but no physical body");
}
}
}
}
But as I wrote above, mixing game logic with session logic seems like a no-go to me - but it would be a work around ‘for now’.