Thanks but when I validated it says
No such function: number:rotate(angle) at line 15, char 52
Can someone explain the way to do it with trig?
Apparently I forgot to add the trig example :S
Here it is
V = owner():pos()+(cosr(curtime()*2)*5,sinr(curtime()* 2)*5,0)
New to the E2? Try my Tutorial:
A Beginners Guide to Expression 2
***Please send a PM before you add me to friends***
Thanks but when I validated it says
No such function: number:rotate(angle) at line 15, char 52
Can someone explain the way to do it with trig?
OK, I got it working now
[highlight=e2]@name Holo Drone
@inputs
@outputs
@persist
@trigger
interval(10)
if(first()) {
holoCreate(1)
holoModel(1,"sphere")
}
holoPos(1,owner():shootPos()+vec(cosr(curtime()*2) *75,sinr(curtime()* 2)*75,-10))
[/highlight]
I hope this is the right way to do it because I don't want to learn wrong. Also let me know if I am over complicating things. I think I can take care of the rest myself but I will post any questions I have.
Last edited by ryan1271; 08-01-2009 at 07:50 AM.
Here's why SpectreCat's line works. You start with the usual parametric equations for a circle in the plane: (X,Y)=(cosr(T),sinr(T)). To embed this in 3-D space, you add the Z-component. (X,Y,Z)=(cosr(T),sinr(T),0). TO center the orbit on the chip owner's position, you just add that to the vector. (X,Y,Z)=owneros() + (cosr(T),sinr(T),0) Finally, you add in some extra parameters to vary the radius and speed.
I'll expand SpectreCat's line a bit to explain. curtime() is a function that returns the number of seconds since the server started.
0.5 is the angular frequency (how many radians orbited per second).Code:T = curtime() / 0.5 V = owner():pos() + 100 * (cosr(T),sinr(T),0)
100 is the radius of the orbit.
If you'd rather use degrees instead of radians, you can change cosr to cos and sinr to sin, then multiply your angular frequency by (180/pi).
EDIT: I messed up with 2 being the angular frequency. fixed now.
Last edited by nescalona; 07-31-2009 at 06:28 PM.
Thanks that helps a lot. I haven't used E2 for very long and that line was too confusing for me but broken down it makes sense.
Anyways, I changed the hologram into an orbiting expression so I can include the ram function later and added some chat commands.
Heres the expression if you don't believe me.
[highlight=e2]
@name Phys Pet
@inputs
@outputs
@persist V:vector Orbit
@trigger All
interval(10)
if(Orbit){V = owner():shootPos()+vec(cosr(curtime()*2)*75,sinr(c urtime()* 2)*75,-10) - entity()os()
entity():applyForce((V*25 - entity():vel()) * entity():mass())}
else{V = owner():shootPos()+vec(0,0,20)}
if(owner():lastSaid() == "-orbit") {Orbit = 1}
if(owner():lastSaid() == "-stoporbit") {Orbit = 0}
[/highlight]
Last edited by ryan1271; 08-01-2009 at 07:51 AM.
Looky here: Text controlled props (by Shoffing), but it takes all the fun out of coding an expression yourself...
(\__/) Expression 2 Resources: E2 Beginner's Guide | E2 Formatting Guide | E2 Function Reference | E2 Examples | Me
(='.'=) PM me code and I'll send it back optimized if possible. (I find it fun dammit!)
(")_(") Drunkie referring to an E2: "It's obvious that Chinoto made this, his coding style is all over it."
I am having trouble with the ram function. I want a chat command where you can specify the person you want to ram. Ex: "-ram Bob" and it would ram Bob.
I also want it to go back to orbiting if it was orbiting me before it started ramming. I don't know how to do either of these things so help would be appreciated.
I also want the model of the expression to be a ball but there is no concommand "wire_exp2_model" How can I change it?
OK I got the model now but I am having problems with a function: findByPlayerName(String)
It says it doesn't exist. Do I need to add something?
Bookmarks