Coded simple movements

Well I am sorry. I am used to having to tag people in something like Instagram or Facebook because that is the only way to tell if they replied to a comment if they won’t look back a few weeks of posts. To really explain what I am trying to accomplish, so I am not sending u on a goose chase, I have a gun, an ordinary model attached to the bottom right screen by the camera node. I right click, and I want the gun to move to a position in terms of the cam position, because world coordinated will not work because I am always moving. I want it to move to the center of the screen, up a bit and back towards the cam(which I have already been able to set) what I want is it to move there in increments, not just snap there. What I don’t know is to move it in an update loop, or independent of the loop by using like a “for” loop or something. Right now, my gun snaps into position, when I want it to transition there at a given speed. I hope this clears some things up. I’m not trying to do anything fancy, just move the object. I understand that you know I am very basic, but I have accomplished all of this before in unity 3d, and implenting it into jme3 seems like an entity different process and that is probably why I am having trouble . I am trying to think of it like unity. Thank you for replying helpfully and kindly

This is why I think it relates somewhat to jme because I have done this before coded in unity. If I have used 2 different programs, and each requires a completely different approach to do something, a book may not be suitable for each programs needs though. I understand what you mean though.

How did you do it in Unity?

The wild goose chases come from when you say “I did X but it didn’t work” and we don’t know what “X” was… and for some users we don’t even know what “didn’t work” is and we are left to guess from among an infinite number of possibilities.

My Sherlock Holmesian debugging abilities only extend so far. :wink:

@jrlowe said: Well I am sorry. I am used to having to tag people in something like Instagram or Facebook because that is the only way to tell if they replied to a comment if they won't look back a few weeks of posts.

To beat this dead horse a little further but maybe provide a useful link at the same time…

Those of us who are serious about the forum read it here:
http://hub.jmonkeyengine.org/forum/latest-posts/

We try to keep it “all read”. It’s a good place for new users to check too because half the questions are asked at least weekly… and half of those are asked almost daily.

In unity, there is a method called lerp which allows you to insert the location of a node for the first parameter, and the speed it moves in the second parameter, and it moves it to that node at that speed. The same thing I am trying to do.

Note: if you were to using Vector3f.interpolate() that way then it might behave similarly… though it would be wrong.

I don’t anything about unity. If this is something you call once and it just does it over some period of frames then they are doing a lot of under-the-covers work for you. If it’s something you call every frame then it may not be working like you think.

For example, if every frame you were to move half way the distance from current location to destination, you would still get to the destination but speed would not be constant.

Anyway, this is not a particularly hard thing to do in JME but it requires that you understand what the update loop is, that you understand what tpf is, and that you understand what interpolate() is.

For example…
Vector3f start = some starting location (could be set to the current location of the Spatial as you initialize this particular animation)
Vector3f end = some ending location

Then figure out how fast you want to get there. If you think in “meters per second” then that’s one thing… for this type of animation it’s most likely that you think “it should take 1 second”

Assuming you need 3 m/sec:
float totalTime = end.subtract(start).length() / 3;

Assuming you just want it to take 2 seconds for the whole trip:
float totalTime = 2;

You will want to keep track of the current time for this animation:
float currentTime = 0;

Then every update:
currentTime = Math.max( currentTime + tpf, totalTime );
Vector3f loc = start.interpolate( end, currentTime / totalTime );
mySpatial.setLocalTranslation(loc);

If you truly have “years of programming experience” then the math should have been the only thing tripping you up and that’s pretty basic 3D math… works the same in 2D… and has nothing specifically to do with JME. It would work for any graphics, just change the types.

Also, any basically experienced Java programmer should be able to take the above and the documentation on JME’s Control and turn it into a general “move from here to there” Control. Exercise for the reader.

Hint: First reply asked you not to do something.

Next reply wasn’t a “sorry, I didnt realise”, no “oh ok, I’ll try not to do it again”, you just did it again…and again…and again… Fine, I can understand you are used to a different netiquette from the twitter style - but the netiquette here was explained and ignored so now it’s just bad manners.

If you can’t even recognise a simple request like that then it doesn’t suggest that trying to help you will get very far :wink: I turned off email notifications from mentions a long time ago for exactly this sort of reason but I still get notifications on the forums so if I’m tagged there had better be a specific reason or I’m annoyed before I start.

I am available as a contract programmer. For gaming stuff I offer lower rates so it’s £50 ($75) an hour. If you want to demand my attention, pay me.

All the information you needed was in the three links I posted. How to place an object, how to make an object move over time, how to work out the new position each frame. You say you have read them, but you clearly haven’t understood them.

hey i wanna be paid game dev too :slight_smile:
got tired of programming boring systems :frowning:

Dude, thanks! I understand it know and will try to get this working sometime today. If it fails, I have another idea for the time being. I guess it was a lot more simple than I thought. It’s dividing up the frames in the current time and moving it that much each frame to the final point I believe.

Yes, essentially. :slight_smile:
You don’t even need the interpolate function, that is just one way to do it.

If worst gets to worst, I could always make a node called ads and attach it to the cam node on the proper place, then I can move the gun up, left, and back until each x,y, and z location are equal to the ads node, and the same process going back. This would work right?

If(gun.getLocalTranslation.getX() != ADS…getX())

Gun.move(move right code);

And do that for x y and z