Savvy001's Recent Forum Activity

  • mudmask

    With Photon there is no need to use setbit/getbit.

    That logic only applies to the C2 multiplayer object.

    Check the tutorial https://www.scirra.com/tutorials/5023/how-to-build-a-multiplayer-game-with-photon

    The part where they say: Send your Position to every player.

    They do the x/y in 2 events, but with tokenat it can be done in 1 event.

    Here is a screenshot from my wip, you can see how it handles the x/y position of players.

    If you want fluid motion, this is the way to go. (and lerp the position on receiving the event)

    Also (just to be sure) photon does not need as much host to peer management, because in a cloud there is actually no host.

    So syncing objects can be done by picking the photon.masteractornr and setting a variable in the game to host = true.

    But if you do not have to, then you can choose a other route.

    This had my mind occupied for a while.

  • Savvy001 Alright, here's what I have currently: http://i.imgur.com/WWjySN0.png

    The opposing player is now in fact destroyed, except it doesn't need to be hit by the bullet to do so. Right when I press Shift.

    It seems I need to find a way identify that the bullet hits only the enemy, because I'm sure what's happening currently is that it's looking for ANY instance of the player to get hit. An easy work around to this though could be to make two separate Player instances for both teams?

    PS: The fact that the player does not need to be hit by a bullet to be killed is because you inverted the event 8 and 9.

    Looking at your image event 8 and 9 say: Player.actornr DOES NOT = photon.eventdata

    It should be: Player.actornr = photon.eventdata

    Somehow you inverted those events "THE RED X".

  • TabloidA

    Also, make sure to use 2 different bullet types of each bullet.

    1 Dummy (spawning on your pc, not harming anyone, this one is purely for visual reference)

    2 Real Bullet (spawning on the other players pc's, harming them when they are being hit)

    Imagine NOT doing this what would happen.

    You fire a gun.

    Bullets get spawned on both pc's, both harming the other player, and both sending event data to the other one.

    This clutters up the data on the photon server, and it could trigger multiple hits when actually it was only 1.

    The right way would be:

    You fire a gun.

    You see a dummy bullet flying.

    All the other players see the "real" bullet flying.

    The player is being hit with the real bullet.

    His game checks if the bullet.actornr is the same as his Photon.myactornr

    If true, then life is substracted, the bullet is destroyed and a event is sent to all other players with the update players life.

  • Savvy001 Alright, here's what I have currently: http://i.imgur.com/WWjySN0.png

    The opposing player is now in fact destroyed, except it doesn't need to be hit by the bullet to do so. Right when I press Shift.

    It seems I need to find a way identify that the bullet hits only the enemy, because I'm sure what's happening currently is that it's looking for ANY instance of the player to get hit. An easy work around to this though could be to make two separate Player instances for both teams?

    TabloidA

    Just add a variable to the bullet.

    When you fire the bullet, set it to photon.myactornr

    Then on collision with the bullet add the condition:

    Player.actornr "does not equal" photon.myactornr

    Then you when you shoot, the bullet can't hit you.

    In my game the bullets all have actornr variables to figure out who hits who

    And keeping the bullets from hitting the player who fired them.

  • mudmask & TabloidA

    When i first started with the photon plugin.

    I used the multiplayer example from the first post.

    It had the same latency mudmask is showing.

    This example capx photon provides, has a event raised for movement, but it is not set at each tick.

    They have it set at like 0.2 seconds interval.

    As soon as i removed that the latency was as good as gone.

    So be sure to check that raising the motion of player characters.

    Do it at each tick, or remove that condition completely.

  • mudmask

    Well assuming you run the C2 version side by side on 1 pc does not make it connect "cross country".

    Meaning the connection and data stays within your home network.

    The photon version does connect to the photon cloud and the data then travels all the way back to you.

    So the photon version gives a more accurate latency representation than the C2 version.

    A question i have to ask, is did you copy paste the movement events from a photon example?

    If so would you please be so kind to show a screenshot of the event that "raises" on motion of the character.

  • Yep.

    The thing is with the multiplayer plugin from C2 (as they told in articles) is that there can be many things "routers" and such between the players destinations around the world.

    This mainly can cause a lot of lag.

    For me why i go with photon is because it minimizes this problem.

    Everyone connects to the cloud.

    Seems to me like the short best route.

  • mudmask

    I had a little lag on the version with the multiplayer object.

    But that could have been some pc stuttering as well.

    Both seem to run fine.

  • TabloidA

    Great.

    Remember you can also put multiple data in the raise event like: sprite.actornr & "|" & sprite.team & "|" & sprite.life

    Than recall 1 of the 3 data using the expression "tokenat".

    (From the C2 Manual)

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    I use this to limit the amount of events raised.

    This way i can get the life/guntype/actornr in 1 go.

  • You are targeting the Photon.actornr to be destroyed.

    So when "on the pc of player A" a sprite is hit.

    The actor number of that pc owner is going to get destroyed on the other players pc.

    Instead of the sprite you actually want.

    Solution is to use the "data" line when you raise a photon event.

    Make each sprite have a variable called actornr.

    On the "is joined" event of that player sprite set that variable to photon.actornr

    Now you have the actornr embedded in the sprite to compare to.

    Then on collision with the bullet raise event with event data sprite.actornr

    Then on received event.

    If sprite.actornr = photon.eventdata(sprite.actornr)

    Destroy sprite.

    Hope it makes sense

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • TabloidA

    How do you handle the collision for the player being hit.

    Can you add a few screenshots?

  • TabloidA

    Depends on the type of game you are making.

    So without knowing that it is hard to tell what the best option is.

    In my wip top down shooter i spawn a sprite "line" on each shot.

    1 on the pc of the player that is shooting.

    And on on all the other players pc's.

    The shooting player spawns a "dummy" and raises a photon event to the other players with the data which players is hit and by who and the type of gun.

    The other players receive that message, and this time the "real" sprite line is being spawned hitting the player, and if the name in the photon event data matches their own player, then uppon this event, life is substracted according to the gun that whas used.

    Then this player being hit raises a photon event with its own life information and player name to the other players updating life status.

    Its flawless

    Note that this method does not involve flying projectiles.

    Its a instant hit method just like raycasting in 3D fps shooters.

Savvy001's avatar

Savvy001

Member since 22 Jan, 2012

None one is following Savvy001 yet!

Trophy Case

  • 12-Year Club
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

14/44
How to earn trophies