Physic mode with a cannon attached to a ship that moves

65 views
Skip to first unread message

Daniel Pers

unread,
Aug 25, 2017, 8:40:07 AM8/25/17
to CoSpaces Scripting
How can a cannonball be thrown into physic mode by a pirate cannon attached to a ship that moves?

Ben Creasey

unread,
Aug 25, 2017, 10:59:42 AM8/25/17
to CoSpaces Scripting
Hi Daniel, 

You can try the coding that I have included. This seems to work quite well, but is also quite basic, so I'm sure you could improve on it. 

You need to attach a "muzzle" to the end of the cannon and reduce its opacity to zero, this basically works as a loading area. Then group a "target" to the pirate ship and place it in the position that you would like the cannon ball to shoot. 

This is the space I quickly built so you can see how it works. 

https://cospac.es/ZG1i

Thanks


Screen Shot 2017-08-25 at 16.57.59.png

Ben Creasey

unread,
Aug 25, 2017, 11:15:48 AM8/25/17
to CoSpaces Scripting
you'll also need to unparent / unattach the cannonball and put it somewhere in the scene where it’s not seen :) 

Daniel Pers

unread,
Aug 28, 2017, 4:32:51 AM8/28/17
to CoSpaces Scripting
Thank you Ben for your help, but I can not keep the cannonball in a loading area.

Thanks

Ben Creasey

unread,
Aug 28, 2017, 5:58:38 AM8/28/17
to CoSpaces Scripting
Hey Daniel, 

The physical ball, the first object that just rolls away can be hidden somewhere - either in the scene or by setting its physical position underground at start of scene. 

Then the coding should work fine and the cannonballs will appear/fire when the action is clicked. 

I hope this helps. 

Thanks
Reply all
Reply to author
Forward
0 new messages