How do I move character a user defined set distance?

Just started using Construct 2? Post your questions here

Post » Thu Jan 07, 2016 8:15 am

Hey
searched but cant find a way of moving a character/sprite a distance as defined by user input.
eg. move character 5 units left, then turn through 90 degrees, where 5 and 90 are values provided by the user.
B
3
Posts: 3
Reputation: 181

Post » Thu Jan 07, 2016 9:31 am

First we would need to know what a unit is and how you define it?
Secondly, What behaviour are you using or do you want to use for the player movement?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 07, 2016 9:57 am

thanks for quick response, using the distance function i have a text box that displays the distance between two objects, i assume it is in pixels, doesnt really matter as i just need the character to move in a straight line for half the measured distance , then rotate through an angle of say 90 degrees. i thought of using custom movement?
B
3
Posts: 3
Reputation: 181

Post » Thu Jan 07, 2016 10:09 am

I'm not sure what it is exactly you want..

But you can get the angle between two objects with

angle(object1.x,object1.y,object2.x,object2.y)

the distance with

distance(object1.x,object1.y,obect2.x,object2.y)

You could use the bullet behaviour, like in the moveto example, or the third party moveto-behaviour or litetween..

To get the point halfway you could use lerp

so x would become:

X = lerp(object1.x,object2.x,0.5)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 07, 2016 10:12 am

thanks i will look into those.
B
3
Posts: 3
Reputation: 181


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest