Disappearing Sprite on SetAsPlayer

Started by Zip, Wed 22/02/2017 00:13:03

Previous topic - Next topic

Zip

Hello there good people,

Would you mind sheding some light of knowledge onto this poor, forsaken soul?

Seriously now. In my envisioned game, the main character should be a able to control other NPCs. I figured for a start to combine interacting with the NPCs  and then in GlobalScript to get

Code: ags


function cREnemy.Interact
{
cREnemy.SetAsPlayer();
}



Which works. The only quirk is that... the main character disappears. Seriously. Sure, the new "player" works fine and moves freely, but the main character vanishes.
I've been searching other forum posts and I think I saw somewhere something on the lines of "there can't be two main characters" (it was for a different question though, at least if my brain is still working). If that's true, is there a way for me to preserve my main character as a static... "object" or something like that (because I'd still like the main character to face the the NPC after it nicked his role as a main character). If there's a way for this to be pulled off, I'm open for all suggestions. This was just a beginning thought to see if this idea can work at all.

I apologise if I misspelled something or I phrased something wrong or something doesn't make sense, this is what happens when my sleep is non-existent (and when the medications stop working 8-) )

Thanks a whole bunch up front.

Crimson Wizard

This should not be happening. The simpliest way to test how this function works is to create a new game of 9-verb template, which already has 2 characters in first room, and implement same character switch there.

There might be something in your game that causes this. I'd check "repeatedly execute", or "on_event" functions for any use of ChangeRoom or ChangeView, and similar functions that may affect character looks or presence in the room.

Khris

This is a good time to note why it is so important to *always* use the player pointer, not cEgo, unless you want to specifically refer to the character: if you don't, it will bite you in the ass.

Zip

I think I got it.

The bottom edge was in line with the enemy sprite, so when I took control over it the NPC the original character changed room (due to the code, which is fine).

Thanks Wizard. God bless. And thanks Khris, I will acknowledge what you said in the future  :)



SMF spam blocked by CleanTalk