How to make a enemy stretch it's arm out?

Get help using Construct 2

Post » Wed Jul 15, 2015 10:16 am

I want a enemy to stretch it's arm out when it sees the player and whitdraw it rigth afterwards.

My thoughts about how to do it: The only imaginable way for this to work i can think off to make the arm a seperate part of the enemy that moves out somehow. Since it stretches out it can't be the full size when it's it not stretched out so it's needs to be cropped at that point somehow. The arm could just be a left and rigth moving object but it needs to be connected to the body. Then we need to make the enemy not stretch out thye arm all the time, only when the player get's close enough. How this can work i am not sure of. Like you can see i don't know to make this work so a helpful reply or a link to guide or another topic that explains this would be appreciated.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Wed Jul 15, 2015 10:22 am

Stretching would be setting the width of the sprite..

So put the origin of the sprite on the left.
Pin the sprite to the player using pin-behaviour.
Give the enemy line-of sight
Stretch (set the width of) the arm when the enemy has line of sight..
If you want the arm to point in the direction of the player, you should set it's angle to something like angle(arm.x,arm.y,player.x,player.y)

If you want it to be better looking, you could change frames of the arm sprite depending on it's width ofcourse..
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 » Wed Jul 15, 2015 12:27 pm

LittleStain wrote:Stretching would be setting the width of the sprite..

So put the origin of the sprite on the left.
Pin the sprite to the player using pin-behaviour.
Give the enemy line-of sight
Stretch (set the width of) the arm when the enemy has line of sight..
If you want the arm to point in the direction of the player, you should set it's angle to something like angle(arm.x,arm.y,player.x,player.y)

If you want it to be better looking, you could change frames of the arm sprite depending on it's width ofcourse..



Thanks for the help. I unfortunaley got stuck on the pin part. I have given both the body and the arm the pin behavior. Then whit the arm i made the event is pinned and after that the action is pinned to body. IThen whit the body i made the event is pinned to and after that the action is pinned to arm. The body moves left and rigth so when i turn on the game the body moves like usual but the arm who was supposed to be pinned to body doesn't follow the body and get's stuck in place. I thaugth that the arm also needed to move left and rigth for it to follow the body. So then i made it do that. The arm still doesn't follow the body. I want the arm to always be at one position in contrast to thye body how much the body an moves. Now it doesn't even follow the body and just falls down the ground and stops moving. How don you make the pin behavior work?
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Wed Jul 15, 2015 12:32 pm

Only one of the objects needs to have the pin behaviour..

From the Manual entry about the pin behaviour:

Simply adding the Pin behavior to an object does not do anything. You must use the Pin action to pin the object to another object.

So you would need something like this:

on start of layout
> pin arm to body
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 » Wed Jul 15, 2015 2:00 pm

LittleStain wrote:Only one of the objects needs to have the pin behaviour..

From the Manual entry about the pin behaviour:

Simply adding the Pin behavior to an object does not do anything. You must use the Pin action to pin the object to another object.

So you would need something like this:

on start of layout
> pin arm to body




The manual says something about mode bar. Where can i see that? The pin behavior has no properties. i did make body pin to body at the start of layout. The body still moves whitout the arm and the arm falls to the ground. Again i need to see a succesfull event sheet.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Wed Jul 15, 2015 2:38 pm

Again i would want a event sheet of how this would work.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Wed Jul 15, 2015 2:49 pm

Body pin to body would work if you are trying to pin the body to itself..

If you want an example of the pin behaviour choose new project inside Construct2 and open the pin-behaviour example..
It's one of the many examples of behaviours and other possibilities of Construct2 shipped with the program..
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 Jul 16, 2015 11:46 am

LittleStain wrote:Body pin to body would work if you are trying to pin the body to itself..

If you want an example of the pin behaviour choose new project inside Construct2 and open the pin-behaviour example..
It's one of the many examples of behaviours and other possibilities of Construct2 shipped with the program..



I did open the pin behavior example and i changed the cog to the body sprite and one of the sheilds to the arm sprite and they finally pin together. It must have been something wrong whit whit the first body and arm. Now i need help whit the stretching part which i not think is documented anywhere. The arm should strtch little by little and reach full width after one second. If you just set in line of sigth and set width to the final width it makes the arm go to it's final width immediatly in one choppy movement. It's supposed to stretch out graudually. You could do this by making it width 70 after 0,15 seconds and width 80 after 30 seconds and so on. The problem is that i don't know how to find a timer that only make a event happen once. X seconds makes a event happen every x seconds but not just one time. Even if i make it all work i don't know how to adjust the appaerance of the arm when it's stretches. The arm should just be wider, not any shorter and the hand shouldn't get wider. How can i make it look good.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Jul 16, 2015 12:22 pm

I made a stretching arm once..

You could use Timer behaviour
to have things happen on timer..

One way would be to set a variable when you want the stretch to happen,
set the width of your sprite to : sprite.width+1 as long as the variable is set
and unset the variable after one second on timer.
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 Jul 16, 2015 2:23 pm

LittleStain wrote:I made a stretching arm once..

You could use Timer behaviour
to have things happen on timer..

One way would be to set a variable when you want the stretch to happen,
set the width of your sprite to : sprite.width+1 as long as the variable is set
and unset the variable after one second on timer.



I did that and it do stretch out it's arm smoothly like it should but it didn't do it when it should. It is supposed to begin stretching out it's arm when it sees the player. It's line of sigth is short so it should only be able to see the player when the player is close to it. When it has seen the player it should stretch out the arm in one second. What really happens is that it stretches out it's arm several seconds after the platyer has came close to it and drags it in and out when the player go to random locations. I hope you understood the problem by all the complexity this reply this answer had. The timer behaviors seem a bit messy. Is there any other thing you can use?
B
11
S
2
Posts: 262
Reputation: 1,309


Return to How do I....?

Who is online

Users browsing this forum: datiel12, Fenix18, tarek2 and 63 guests