rohamc's Recent Forum Activity

  • Hi guys, I'm trying to make my player move with touch controls, more specifically with swipe movements (for a mobile game)

    I would like the player to move forward while the touch is directly in line with the X position of the player, and move at an angle towards the touch position if the touch position is not equal to the X position of the player.

    The reason I do not want any car behaviour on the player is due to the fact that you need acceleration for steering to work but I need to make a player than can "steer" without any acceleration because on top of all these controls I want the users of this game to be able to make a swipe motion to be able to give the player a kind of drifting effect when the user swipes the screen on an arc towards left or right, all this should be doable with and without any Y movement from the player.

    Is there any way I can achieve this? I would appreciate it if you could guide me in the right direction, I would like to be able to solve this on my own so I can learn better but I need guidance on where and how to get started with it, some ideas would be nice and always welcome but please don't solve it all if you know how to do it because then I won't learn anything!

    Many thanks in advance

  • I have managed to fix it now and the player moves correctly using distance calculations as its speed:

    so the touch distance now affects the player speed by increasing its speed the further away the touch position is and likewise the player slows down as it reaches the touch position.

    It was achieved by the following modifications to the events:

    Original Events:

    Touch> is in touch> Player > move 300*dt pixels at angle (self.X, self.Y, touch.X, Touch.Y)

    System> compare two values> distance (Player.X, Player.Y, Touch.X,Touch.Y) > 300*dt

    New Events:

    Touch>is in touch> Player> move distance ( Player.X, Player.Y, Touch.X, Touch.Y)*dt pixels at angle (self.X,Self.Y,Touch.X,Touch.Y)

    System> compare two values> distance (Player.X, Player.Y, Touch.X,Touch.Y) >= 300*dt

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe you can create some rectangles and use them as "areas" and set: if touching rectangleX > set char speed to X; if touching rectangleY > set char speed to Y. Got it? If you put them on the HUD layer with 0 parallax they will be on the screen until you decide don't.

    If you have any doubts, just let me know and I can make an example for you :3

    I dont think this would be appropriate because I want the speed to change based on touch distance from player, if I create rectangles and give each a certain speed that speed will be set even when the player is on said rectangle, so for example the player is currently on RectangleY and it wants to move towards rectagleX and it will do so at the speed set on rectagleX, lets assume RectagleX is the furthest point from RectangleY so the speed in this isntance would be the fastest possible; but if the player is in rectagleX and wants to move slightly to the left but still in RectangleX then it will still use the speed set on RectagleX whereas the speed should be considerably slower since the touch position is only slightly to the left of the player!

    I doubt there is other ways of doing it other than distance calculations but do correct me if im wrong because I still havent figured out how to do it! lol

  • You might want to look into using Lerp , it will let you move to a distance based on time .

    player>set x to lerp(self.x,touch.x,time*dt) ,where time can be input from a distance calculation.

    Thanks for the input Granpa I added both lerp actions for X and Y and it just made the player move extremely fast towards the touch position hah, I need to make the distance calculation and use it instead of "time" but do I do it under a variable because it will change? or is it simply just another event?

    I will google it to find the solution myself and If I do I will post back so I dont waste anyones time but meanwhile anyones input would be greatly appreciated.

    thanks again

  • Hi guys im new to contruct 2 and im trying to create a player who is controlled via touch input, I would like its movement to increase based on touch position/distance (the further away the faster the player speed); for example if touch is at a distance of 100 px from the player then the player would move at speed of 10 to that position and decrease while reaching the touch position, if touch is at a distance of 200 px from the player then it wil move at a speed of 20 to that position and decrease while it gets closer to the touch position until it reaches a speed of 0 (position of player = position of touch).

    my events at the moment are like this:

    Touch> is in touch> Player > move 300*dt pixels at angle (self.X, self.Y, touch.X, Touch.Y)

    System> compare two values> distance (Player.X, Player.Y, Touch.X,Touch.Y) > 300*dt

    so my question is what do I have to do to be able to increase the speed of player movement based on touch position?

    what events and actions do I have to add or change to allow for this to happen?

    please bear in mind that I have only had construct 2 for 1 day so I apologise if this is very basic but I cant find any examples or tutorials on something like this.

    Many thanks in advance for your help.

rohamc's avatar

rohamc

Member since 6 Jun, 2016

None one is following rohamc yet!

Trophy Case

  • 8-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

10/44
How to earn trophies