generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Random turning for an AI

Previous Thread :: Next Thread 
Wheatlies is online. Wheatlies
Joined: 30 Jun 2010
Total Posts: 230
26 Feb 2012 01:55 PM
Basically I am working on a bunny AI, and I need it to turn to a random direction before traveling and jumping for a bit. I know how to make it move forward but I am having trouble making it turn to a random angle, any suggestions? I know I could just set a CFrame to a random angle, but that would have no tweening and I would much rather use some sort of force.
Report Abuse
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
26 Feb 2012 01:56 PM
Body force?

`*\~-{ Are we there yet T.T? }-~/*`
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 01:58 PM
Like this?
http://www.roblox.com/Testing-Mini-Tanks-Back-in-Motion-place?id=19815739
I use BodyAngularVelocity for turning.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Wheatlies is online. Wheatlies
Joined: 30 Jun 2010
Total Posts: 230
26 Feb 2012 01:59 PM
Could you give me some example code please?I've tried using BodyAngularVelocity before.
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
26 Feb 2012 02:02 PM
All the body motion instances lag and are glitchy. It is much preferable to use cframe steps for all motion.

Is the rotation completely 2 dimensional? If that is the case, you can use some basic trig to identify the angle between the current lookvector and a randomly generated one and then cframe a small change in that direction until it reaches the desired vector using a for loop.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:02 PM
Well, thanks for checking it out.

   Engine.BodyAngularVelocity=Vector3.new(0,1,0)

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:03 PM
"All the body motion instances lag and are glitchy. It is much preferable to use cframe steps for all motion."
>Doesn't know whut he's talking about.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Wheatlies is online. Wheatlies
Joined: 30 Jun 2010
Total Posts: 230
26 Feb 2012 02:06 PM
Whenever I use the method of Applying BodyAngularVelocity in a given direction it continuously goes in that direction, so should I just add and remove it every time I want to turn the bunny?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:09 PM
If the y axis is positive the bunny turns left, else if it's negative, the bunny turns right.

bunny.Torso.BodyAngularVelocity=Vector3.new(0,1,0)
wait(2)
bunny.Torso.BodyAngularVelocity=Vector3.new(0,-1,0)

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
26 Feb 2012 02:11 PM
">Doesn't know whut he's talking about."
>>Thinks trolling makes him cool.

Using CFrames instead of body instances:
1. cuts down on the motion involved in a movement by specifically defining each translation.
2. reduces the load on the physics system by reducing the number of unanchored bricks.
3. Greatly reduces any out of sync effect from global scripts and the locally ran body instance movement.
4. Allows for complete, custom control of an objects motion.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:12 PM
>.<
>Still doesn't know what he's talking about.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:13 PM
Also, who said I was trolling? You legitimately don't know what you're talking about.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Wheatlies is online. Wheatlies
Joined: 30 Jun 2010
Total Posts: 230
26 Feb 2012 02:15 PM
It's a bunny, I would use CFrames if I were making bullets. I want physics on the bunny, with CFrames unless I coded otherwise (which would be a bit of a hassle to me) they'd be fusing into blocks.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:17 PM
Using CFrames with bullets wouldn't be the best, unless you're raycasting.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
noobkid is not online. noobkid
Joined: 17 Sep 2007
Total Posts: 649
26 Feb 2012 02:18 PM
@nate,
Body forces does lag for me more than other objects>
wont move smoothly
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
26 Feb 2012 02:27 PM
"Also, who said I was trolling..."

-_-

Please, maybe think about what you say before you just make inflammatory comments. I've been scripting on roblox as long as you have, a few months longer in fact, I think my observations on using the ROBLOX API are warranted a little more respect than "He doesn't know what he's talking about." If you said "Actually, that is incorrect because of such and such which means this and that" then there would be no problem. Unfortunately, you didn't support your opinion and instead made unwarranted offensive remarks. That is the definition of trolling.

IF YOU WANT SOME SOLID EVIDENCE for the merits of CFrame movement over body instance movement, here are some links to two games, the first uses cframes, the second uses bodyvelocity and bodygyro. The first would have been enough, but the body instance movement lagged so much that all of my players DEMANDED THAT I REMOVE THE BODY MOVEMENT SHIPS.

Star Command - cframe motion
http://www.roblox.com/Star-Command-Beta-v2-2-Multi-Selection-Added-place?id=13729582

experimental starfighter place - body instance motion
http://www.roblox.com/Starfighters-3-place?id=13430606

The first link has a whole lot more going on, game engine scripts, hundreds of lines for the user interfaces, a lot more bricks moving around, more bricks in general, etc., etc.


It has half or less the lag of the second link.

Please stop displaying your ignorance and immaturity. It is embarrassing.
Report Abuse
noobkid is not online. noobkid
Joined: 17 Sep 2007
Total Posts: 649
26 Feb 2012 02:29 PM
You shouldn't say something like that to nate

H3 omgh4xrs j00
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 02:30 PM
You're comparison is horrible. You're comparing CFrames to BodyAngularVelocity and not what it's being used for. In this case, you're moving an object based on physics, you wouldn't want a bunny walking into a brick, would you? Compare the options to this scenario. Why do you think people use body objects to move planes and such, and not CFrames?

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
26 Feb 2012 02:38 PM
I will pm you instead of overloading this thread.
Report Abuse
Wheatlies is online. Wheatlies
Joined: 30 Jun 2010
Total Posts: 230
26 Feb 2012 03:03 PM
Right, well, now I have another problem, I need it to jump and whenever I try to use bodyVelocity for that it behaves oddly.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
26 Feb 2012 03:10 PM
The problem with bodyvelocity (for you) probably occurs because you're not moving it in the direction your AI is pointing (use CFrame.lookVector)

As for jumping pastebin.com/qEctjpNx

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
26 Feb 2012 03:17 PM
Bodyvelocity acts on all three axies...if you want a 'jump' motion I would recommend using the bricks velocity property instead of a body instance so you get parabolic motion with out a lot of extra hassle. To do that you would have to set the y property of the maxforce to 0 for the duration of the jump.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image