WheatliesJoin Date: 2010-06-30 Post Count: 230 |
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. |
|
EverestyJoin Date: 2009-10-08 Post Count: 6156 |
Body force?
`*\~-{ Are we there yet T.T? }-~/*` |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
WheatliesJoin Date: 2010-06-30 Post Count: 230 |
Could you give me some example code please?I've tried using BodyAngularVelocity before. |
|
|
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. |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
"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." |
|
WheatliesJoin Date: 2010-06-30 Post Count: 230 |
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? |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
|
">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. |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
>.<
>Still doesn't know what he's talking about.
"Bro five! Wear this to let everyone know you think they deserve a high five." |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
WheatliesJoin Date: 2010-06-30 Post Count: 230 |
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. |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
noobkidJoin Date: 2007-09-17 Post Count: 649 |
@nate,
Body forces does lag for me more than other objects>
wont move smoothly |
|
|
"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.
|
|
noobkidJoin Date: 2007-09-17 Post Count: 649 |
You shouldn't say something like that to nate
H3 omgh4xrs j00 |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
|
I will pm you instead of overloading this thread. |
|
WheatliesJoin Date: 2010-06-30 Post Count: 230 |
Right, well, now I have another problem, I need it to jump and whenever I try to use bodyVelocity for that it behaves oddly. |
|
nate890Join Date: 2008-11-22 Post Count: 21686 |
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." |
|
|
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. |
|