Soulmachine's Forum Posts

  • I understand. Thanks

    I was wondering. Is it best practise to disable physics if you have to move an object (Position it) - that has the physics behaviour assigned to it?

  • Ok. I'll consider disabling it to see what happens. It may be easier and to avoid "strange" behaviours.

    Physics are a bit unpredictable and I have issues and "strange" behaviours sometimes. And it only happens after I've moved the object. The performance are no problems though.

    I need things from the object, instance variables, position and such, so I cant destroy it without big problems.

  • I'll explain more.

    I have a player that throws an object. And I'm using physics.

    When the object hits a wall - it instantly has to stop. Like if you throw a knife into a wooden wall. The same has to happen when the object hits another player.

    To achieve this, I set the objects velocity and angular velocity to 0 when it collides with a wall/ground or another player.

    After this has happened - it's the other players turn to throw. So I reposition the object to the another player.

    I do not want to destroy my object, just reposition it after it has "landed/hit something"

    I'm doing a multiplayer game, so it's a bit complicated to do some things, that normally would be much easier if it just were single player.

  • Which is best. To set Physics Velocity X,Y to 0 or to disable Physics... If you want to move an object. For example the player has to spawn in a new position.

    I have an object that after it has landed, I need to respawn it ( move the object ) to another location. At the moment I set Velocity to 0 and Angular velocity also to 0. After that I position my object to the new location. ... I forgot.. I also set the World.Gravity to 0 before I move my object.

    Is it better to just disable Physics while I reposition my object you think?

  • Hello.

    I need tips and suggestions setting up the Stepping iterations and Stepping mode in Physics. I think they may be responsible for some small lags in my game.

    I get a small lag with the physics ( i think it's the physics ) in my game and I wonder why that is, and if I can do anything about it?

    In my game, I have a player that throw an object - applying a force in a direction. Also applying physics angular velocity so the object rotates. It works very good... The object gets thrown and rotates in air, as I want. But sometimes when the object are in air, I get some kind of flickering lag. You know... it feels like flickering, like when you play a game and the screen cant keep up with the framerate. But also the object can slightly lag ( freeze ) for a very short while, and then "jump" a short distance - as if the object are synchronizing something?

    However the game works pretty nicely with the performance - but I was wondering if I can fix this small problem?

    When I'm testing at my computer in Firefox. I have 60fps most of the time. Sometimes it can drop down to 45-50, but only for very short moments.

    This is a multiplayer game and I only have one single object with physics in the game. The players take turns throwing it.

    I haven't change any default settings for the physics: Stepping iterations and Stepping mode. So I think they are set to standard as you can find in the manual for the Physics behavior.

    I would be very happy if anyone with experience with these values could give some pointers what they feel works best - performance wise.

  • The only way I manage to do it - is to solely have the actions in the Host group. But then it kind of lags for the peer :/

  • I understand...

    So you think it's better to dedicate a whole group for mouse or touch? Yes that may solve it perhaps. I will try it out.

    At the moment I have mouse/touch detection at the first layout and I set a variable "Mouse" or "Touch" - that I use to distinguish between the two.

  • I have a bug/issue in my game - that I'm having troubles to sort out.

    My game rely on the coordinates for the Mouse or Touch - but their mechanics are a bit different.

    I have a 2 player realtime multiplayer game - and I've used the Multiplayer - Real-time game, Example in Construct as a template when I created my game.

    It works basically like this:

    When it's a players turn, they supposed to throw something. They aim by clicking and holding down mouse-button and drags in a direction. When they let go of the mouse-button they throw their object.

    What happens are that a small cross (sprite) gets positioned where the mouse clicked, then a line (sprite) gets positioned at the same position - and the line.angle gets pointed towards the Mouse.X & Mouse.Y ..The line.width also get set, and it's the distance between where the mouse clicked, and where the Mouse.X & Mouse.Y are. If the player are on a touch-device it's the Touch.X & Touch.Y instead of the Mouse.X and Mouse.Y

    When the player release mouse-button OR stop touching the touch-device: an object gets thrown. The object gets thrown in a direction and uses the line.angle for that, and the force to throw the object it uses the width of the line.

    So the angle and the width are very important for this to work.

    This works very nice, both for Player 1 (the host) and Player 2 (the peer) but NOT if Player 2 are on a Touch-Device?

    However it works on a touch-device if you Host the game ( you are the Player 1). But it does not work if the touch-device are the Peer ( Player 2 ).

    My problem - when I've researched this is that the way the Mouse-mechanics vs the Touch-mechanics works is that: On a Mouse button released - the mouse-cursor ( the Mouse.X and Mouse.Y ) are at the same place ...just where you released the mouse-button.

    But on a touch device: On touch end the Touch.X and Touch.Y get's set to Touch.X = 0 Touch.Y = 0

    This is a problem for me in my game, as I use the angle of my line for the direction to throw my object. And I use the width of the line as a Force to throw the object.

    If the Touch.X & Y gets set to 0,0 before I may throw my object, it's not good.

    I believe it may have to do with an multiplayer on client update issue.

    The Peer manages to set the Touch.X & Y back to 0,0 before construct can perform the actions for throwing the object.

    As the line.width and line.angle uses the Touch.X & Y coordinates ...This phenomenon really screws things up.

    As the multiplayer example, I use lookx and looky input values for the Mouse.X & Y. And I've done the same, but created other input-value-tags, for the Touch.X & Y

    I use the Common group, as in the multiplayer example, to perform my actions when the input-bit are set to 1 or 0. ( In the example you fire your laser )

    It have been easier, and worked so good but I may have to do this somehow in the Host group - cause I may feel construct will not be able to sync stuff correctly. But it will be much more troublesome to sort all the things out that needs to be done. For example I have things that needs to get flipped and mirrored, depending on if you are the Host or Peer ( Player 1 or 2 ). Also I need to use the pin behaviour. And some more stuff, that's hard to make work for the peer unless you broadcast multiplayer-messages from the Host to the Peer. And this gets very disorderly so quickly, I rather avoid it.

    Has anyone had similar issues like this or having idea´s on how to do this in a better way?

    Thanks a Million!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It worked...

    I couldn't open your capx, cause it was Construct release 208 and I'm currently on 206. I downloaded the 208 and in the meanwhile, while I waited for the download, I tried to solve the problem with your info in your reply. And I got it to work, both for the Host and Peer... This is GREAT thanks.

    ...was a bit tricky as the host and peer update their values a bit different. I got the peer to work instantly, but had to tweak some more with the host.

    Now all I have to do is finish the rest, and actually put in what's gonna happen after they aimed... It's tricky with multiplayer to do stuff, but the more I work on it, the more I'm getting the hang of it. This is my third multiplayer game, and I'm still having problems and getting confused.

  • Thanks Lennaert.

    I will research this you've sent me, and see if I can use it. It looks promising.

  • Hello Lennaert, thanks for the reply

    The problem gets tricky this way, cause in my game I need to do things separately on certain conditions with the inputs.

    I'll try explain...

    I have a player that are going to aim something. The way he do it is that he click and hold down the mouse and then drags in a direction.

    What the player see, is a small cross where the mouse-pointer was when he first clicked. ... then he still holds down the mouse and drag in a direction. Then he see a line between the cross, and where he now has his mouse pointer. ... it's kind of drawing a bow and aiming.

    So when I did this game as a single player at first. I used 3 conditions.

    * On Left button clicked - I created the cross, and a line, at the mouse pointer position, and saved the coordinates in a variable.

    * Left button is down - I use the distance to set the width on the aiming-line and also sets the angle pointing towards the cross ( coordinates )

    * Left button is released - the projectile gets shot away.

  • Hello!

    How do I use "On Left button released" in multiplayer - for the peer inputs?

    I use the Example for the Multiplayer - real-time game in construct as a starting point when I do my multiplayer games.

    In the Peer-Group where the peer send it's inputs to the host, there is an "On client update" and "peerid = Multiplayer.MyID" - condition. Then below that there's the sub-events that test the condition for an input. For example: Mouse - Left button is down... or Keyboard - Left arrow is down... and so on.

    However I can not choose "On Left button released".

    I'm allowed to choose it though in the Hosts Group.

    I know it's about the way constructs events work and why I'm not allowed as the event-sheet are set up this way in the example. But I would like to know if there's a workaround somehow to be able to use the input-condition "On Left button released"? Should I perhaps try to do it in the common group?

    The only thing I can think of at the moment - to be able to still have something in the inputs in the Peer-Group - is to design some kind of boolean-variable that get set as soon the mouse button is down, and then resets when the button is not. ... And use that somehow.

  • I apologize for my not so crystal clearness, but I'm stuck and do need some pointers to a direction where I can learn more and get un-stuck.

    I've read and done the Multiplayer tuts backwards and forwards, especially the real-time tutorial. Even though I do not completely understand it to 100% - I understand most of what the events do but not always WHY it needs to be set the way it is.

    I've used the multiplayer-real-time tut way of constructing a game and I've come pretty far with my game. The problem is... I can do all the functions and things I want the game to have if it were a single player game, but now I can not work out how I should place these functions.

    I've managed just the basics so far... to make the players move with direction animations. To be able to shoot using a Finite State Machine. To explode when they die. To change the speed in different wind-conditions. I made the controls for both mouse-control the player-objects, and to control on a touch-device. And some other things so I have the basics for the players like, move/turn, shoot, kill, get killed.

    I have lot's of needs but I'm not sure the best way to implement them, or if it's even possible?

      I need to make the players spawn at different spawn-places. Using sprites for players to spawn on. I need to make the player invisible when they die cause there is spawning an explosion on top of them. I would like to have some things fade in or out. Some things to flash some things to get pinned to other objects I would like some objects and information be showing for the peers but dont be forced to sync them I would like to use the behaviour timer for objects. I want a fast network-multiplayer-game and do not waste bandwidth if I can avoid it.

    This game is meant to be able to have up to 10 players at the same time. So to avoid game lagging is a priority.

    I need pointers to work out how to know where to put events in the right places. How should I think and can anyone help me to places or tutorials where I can get the information? What's the approach of thinking here?

    What is possible to do in the HOST group and what is not? So it will show not only on the host but with the peers also.

      I know I can move my player (peer) to different positions. I can set the peers variables I can change arrays I can test if things are overlapping or collisions. I can make the peer see a variable if I synced it. I seem to NOT be able to... set a sprite invisible use many of the behaviours like flash or pin to. Set animation frames so the peer can see set the animation

    I get crazy

    I can't figure out the route... the pathway to think - if I want a function in the game.

    It feels like all I do in the host group - the peers can not see.

    If I for example want the peer to see a change of a sprites animation I need to like set a variable at the Host-Group then at the Common-Group make the peer change the animation. Or make an input in the peer-group

    It's completely mind boiling up to 500 Fahrenheit exploding brain kind of thing - this...

    but I don't want to give up have I come this far.

    I have a learning by doing - do some research - way of doing things, but this multiplayer thing are pretty advanced and sometimes I just cant find the right info anywhere. Like sometimes I do not know what I need ask. So any pointers here to get me on the right track are so appreciated.

    Thanks!

    ///Soulmachine!

  • Hi guys!

    Just a quick question... ( I hope )

    Do the pin to behaviour work in multiplayer for the peer? With the peer meaning not the host.

    I have a peer-object for all players and in that object I have a container with an object (sprite) that I want to pin to the peer.

    Do I need to sync the pinned objects when they are in a container and are pinned? I do not need see them if I play as a peer. Only the host need see them. They DO need to move with the player ( to be pinned ) for the host but the peer do not need see them visually.

    I ask this cause I need to pin some invisible sprites on the player for detecting where a mouse/touch-device has clicked/tapped.

    And I was thinking... as long as the host can see/keep track of the objects, the host could decide for the peer if the pinned sprites are clicked on. Am I thinking totally wrong here?

    I wanted to save some bandwidth and not being forced sync these pinned sprites. And also these sprites does not need to be visible for the game plays sake.

    I have a solution where I every tick position the sprites, but it would be nice to be able to when peers connected pin those sprites to the peer-object.

    At the moment it works for the host, but not the peers.

    I'm a bit lost sometimes with the multiplayer awkward thinking. Like If I for example place a normal button on my HUD. Both the host and peers can see it. I do not need sync it. Then in my (Common) - event-group I can use that button for example menu operations and so on.

    But if I have these sprites I want to pin. I can see them on the peer, when I'm looking in the host game-window. But they do not get pinned? They just stay at the position where the peer got created.

    But the hosts- sprites do get pinned.

    Thanks for listening so far.

    In the future I will post some more questions about multiplayer. When I have a bit more structure on what I need ask. Sorry for my disorderly questions.

    Right now I'm learning by doing with the multiplayer, using the tutorials.

    Later on I'm encouraging everybody to help out straighten out some questions and give good pointers to what direction yo need to go, when starting to program multiplayer projects. Especially the thinking.

    Some general praxis on the workflow and planning is needed - to convert a good working game you've made in singleplayer - into a multiplayer.

  • That is correct.

    ...That's pretty much what I did.

    But instead I have it in a Function called "Initialize" And that function is the first thing (the first Action) in the Start of layout.

    "On start of layout" - Function | Call "Initialize"

    and in the function On "Initialize" I have - Player | Destroy

    Directly after I then have Create | Player ( or I have an Object on the layout called SpawnPlayer that then spawns the player )

    If you simply put Player | Destroy in start of layout it should do the same I think. Instead having it in a INIT-function like I have.

    At least that fixed my problem.

    The problem I had was that all my towers, and also normal enemies that use the Tower and/or LineOfSight behaviour, targeted the Player object OUTSIDE the layout.

    And after the Destroy Player fix, my game have worked fine.

    I recommend all people, if you plan to use restart layout in your project - to test often what happen when you restart.. after you did some work, cause unexpected things could happen.

    I'm glad I could help.