Game Development Community

setting world limits and collision bounds in script????

by J Raven · in Torque Game Builder · 04/25/2012 (5:32 am) · 7 replies

im trying to set the world limits and collision bounds for an object in script as it spawns

im thinking that it should be set inside the object but im not sure if thats correct or what exactly to type

this is the object as is at the minuite

%basicEnemy = new t2dAnimatedSprite()
   {
      sceneGraph = %this;
      class = "basicEnemy";
      layer = 4;
      size = "16 16";
   };


for the world limits i was thinking of doing this (changes between the comments)

%basicEnemy = new t2dAnimatedSprite()
   {
      sceneGraph = %this;
      class = "basicEnemy";
      layer = 4;
      size = "16 16";

      //added these-----------------------
      limitMode = "bounce";
      minX = "-150";
      minY = "-75";
      maxX = "150";
      maxY = "75";
      callback = true;
      //end-------------------------------
   };

or something like

(%this.setWorldLimit();

in the objects onAdd() function but not sure exactly how to send it the required settings

as far as collision goes not a clue at all how to set them in script so would really appreciate a hand with this or a point in the right direction

any help on this would be greatly apperciated as im a little stumped right now

thanks a lot

J.

About the author

www.goal7.co.uk


#1
04/25/2012 (7:58 am)
Just a thought!!!

will this work????

%basicEnemy = new t2dAnimatedSprite()
   {
      sceneGraph = %this;
      class = "basicEnemy";
      layer = 4;
      size = "16 16";

      //will this work-----------------------
      worldLimit = "bounce, -150, -75, 150, 75, true";
      //end----------------------------------
   };

bit of a crazy idea but i know that

Quote:The getWorldLimit() function returns a string "list" of values for the world limit. The string looks like "limitMode minX minY maxX maxY callback".


from the basic tutorial 3 on tdn
#2
04/25/2012 (11:56 am)
Pretty sure that already exists:
object.setWorldLimit( bounce, "-100 -100 100 100" );  
or
object.setWorldLimit( kill, "-100 -100 100 100" );  
or
object.setWorldLimit( clamp, "-100 -100 100 100" );
#3
04/25/2012 (12:12 pm)
thanks Patrick was pretty sure it did exist but was unsure of exactly how to call it

#4
04/25/2012 (12:26 pm)
No problem; some very helpful stuff here.
#5
04/25/2012 (12:34 pm)
Excellent thats fantastic Patrick thank you was searching TDN all day but totally missed that.

Thanks again
#6
04/25/2012 (1:01 pm)
No problem; navigating the docs took me a long time. Other very useful landing pages here and here.

And if you still can't find what you're looking for, use this.
#7
04/25/2012 (2:09 pm)
Brilliant thank you very much Patrick you have helped me out loads

Ive managed to do what I wanted thanks to a good bit of reading from your links

Got the world limits set and the collision poly

Cheers J.