How do I set a bullet angle relative to my character

Get help using Construct 2

Post » Thu Apr 13, 2017 1:42 pm

Hello everyone,

I'm quite new to construct2 and I've the feeling mine could be a very trivial question. The main character in my game is a boat equipped with two cannons mounted at an angle of 45 degrees (+45 and -45 to the boat direction).
I would like my boat to shoot a cannonball at the given angles on mouse click. I've added two image points (one per cannon) and added the corresponding spawn event. Together with the spawn action I've also added to my 'cannonball' object a set angle of motion action. I set the angle to:

Ship.Angle + 45
(Ship is my character)

However, when I'm running the game the bullet is not considering the 45 extra degrees I've added. The bullet is following the boat direction (I don't know if it is relevant, but it has a car behavior) but is not applying the angle.

Could you please help me?

Thanks in advance to anyone answering.
B
4
Posts: 2
Reputation: 204

Post » Thu Apr 13, 2017 7:46 pm

If I understand you correctly then just give your Cannonball "When clicked - set bullet angle towards Mouse.X, Mouse.Y
I guess =P

Hope it helps
B
5
S
1
Posts: 6
Reputation: 339

Post » Thu Apr 13, 2017 8:01 pm

The moment that you spawn the bullet, it is not moving yet.
The bullet acts like a car-in-reality.

When the car stands still, turning steer will not change the direction of the car.
Setting angle of motion action is like steering the bullet.

But, the angle of motion aligns to the actual angle of the bullet, when the bullet is not moving.
Same is true for the car, re position it with a forklift, and you can change its direction while it is not driving.



So ...
Spawn the bullet.
Set its angle to ship.angle +- 45 (sprite > Set angle)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Apr 13, 2017 9:00 pm

Thanks 99Instances2Go, that worked perfectly.

Thanks for your explanation as well, now the mechanism is much clearer to me.
B
4
Posts: 2
Reputation: 204


Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, Yahoo [Bot] and 49 guests