[Solved] Weld Joints not working

Jaymer

  • Posts: 17
Hello!

Situation:
I'm making a modern copy of Tank 1990. I've had a few problems with it but what's bugging me right now is the problem with Weld Joints.
I've got a bonus-like actor that upon collision causes a player or an enemy to spawn a new actor - shield, that then follows the one who triggered it .
I've found out that to make the shield follow (or rather "glue" it to an actor) I can use the weld joint.

Problem:
I use the code as shown in the screenshot.
A Player or an Enemy creates a new actor (Shield) and then creates a Weld Joint between self and the last created actor (Shield).
Unfortunately when I start the game, the shield actor is created but doesn't follow the target (its creator).

What's more annoying is that it works just fine with the Crash Course Game, where I can "glue" Clown to Noni using the same blocks as in my game.
What could cause it to fail in my project? Gravity? Group of actor? Collision shape as sensor?

I use the Stencyl build 8868.

Help, please!  :'(

« Last Edit: August 18, 2016, 08:24:02 am by Jaymer »

JeffreyDriver

  • Posts: 2262
If I was adding a shield to an actor I'd just get the player XY values as attributes and set those to the position for the shield, doing away with the need for using joints.

Jaymer

  • Posts: 17
If I was adding a shield to an actor I'd just get the player XY values as attributes and set those to the position for the shield, doing away with the need for using joints.

That'd work if only player could use that shield and there was one shield at a time. I'd like to allow enemies to use the shield bonus as well and here starts the problem. In game there could be many instances of the shield actor and many instances of the enemy tank (I'm making it a behaviour working for players and enemies).
Guess I could do something like giving actors IDs and using it in the shield actor's behaviour to find that one tank it's supposed to follow, but I think it's the hard way.

The weld joint seems to be an easy way but it doesn't work in my project (no idea why).

captaincomic

  • *
  • Posts: 6108
Quote
Collision shape as sensor?
That may be the problem. Have you tried it with solid collision shapes?

Jaymer

  • Posts: 17
That may be the problem. Have you tried it with solid collision shapes?

I've made another game to make some testing.
It turns out it was all because I had "Can Rotate?" and "Affected by Gravity?" on the Shield Actor set to no.
Once I set them to yes, everything works just fine (and even doesn't rotate if the actor it's glued to doesn't).
Then I can set the Shield Actor to not collide with second actor or make it a sensor and it still works.

I guess it can be marked as solved?