Rotating a mesh.

Hello so I recently just randomly open a project from a long time ago and saw ugly it was. Was messing around with some rotations. What I wanted to do is make the ball you control less stiff (b4 it just was a bouncing ball - but it didn’t rotate at all). Now when I added a transform.Rotate and did a (1,0,0). It worked fine, but one small… BIG PROBLEM. The way the movement is set up, you allays are moving in the way you are facing. So if I rotated the object it would rotate the way it move… big no no.

Anyways to the question:
Is there anyway to rotated the mesh* of sorts instead of the whole object, to still get the object to look as if it is rolling. (its a sphere). So can I rotate the textured mesh that is on an object, w/o affecting the X, Z, Y, axis of the object.

As I always say, the answer to the question ‘is there any way to…’ is almost always ‘yes’.

In this case, it sounds like maybe what you’re looking for is a parent-child object hierarchy; the parent object would handle the object motion, while the child object would handle the ‘rolling’ animation effect.

Another option would be to use a rigid body, and apply forces to move the ball in the desired direction.

I do use a rigid body fro my movement scripts but it sends the direction according to the x axis or one of them.

I’m not quite sure what you mean, but you can move the ball in whatever direction you want; just use one of the ‘add force’ functions with appropriate arguments.

I already have movements and everything, I want a way to make the mesh texture move, without changing the rotation of the object, only the mesh rendering.

An answer to everything eh :stuck_out_tongue:

Yes, that’s right :slight_smile: However, it’s hard to provide an answer when the question itself isn’t yet clear :wink:

Ok, my next question would be, why do you want only the texture to change, rather than simply allowing the ball itself to rotate? Is there a reason just letting the physics engine handle the rotations wouldn’t work?

If you do want to handle the rotations yourself, then it seems to me that the parent-child method I mentioned earlier would be more suitable than trying to animate the texture coordinates. The parent object could have the rigid body component attached to it and have its rotation frozen; then, the child object could have the mesh attached to it and be animated to create the ‘cosmetic’ effect of the ball rotating. (There’s some fairly straightforward math you can use to compute a ‘rolling’ rotation based on a translation and a surface normal.)

I know for a fact I recall seeing how to make somethign that might be similar enough to get you started in the Lerpz Tutorial.

its for a forcefield that surrounds a spaceship. Look in that PDF- the code is there.

Look on page 44.

as you said:

they are using the code to scroll a forcefield, but I’m sure a bit of modification could get it to rotate the texture, without affecting the mesh’s rotation.

I cant just rotate the object becuase of how the movement works, and it will cahnge teh direction that teh ball moves, It can only move on direction for this game. SO if you start rotatign eth object, then it will change the direction that it is travelling.

It’s certainly possible to set things up so that the rotation doesn’t affect the direction of motion. I don’t fully understand what the desired behavior is though, so I can’t really comment further.

Can you provide a link to a video or post an image or something showing what you mean?

From the question, it looks like physics are your best bet, In the case of rolling you choose one of 8 directions based on your possible key combinations, W, WD, D, DS, S, SA, A, AW. You then take a list of Vector3’s that are the angles that you want to rotate (1,0,0), (1,0,-1) and so on(These are axis directions, not direction directions) that match the key combination that you pressed, then you Rotate or AddTorque around the camera’s TransformDirection.

The question isn’t that complicated, he is simply asking how to make it look like it is rotating in a direction pushed.

You can increase that by using a Plane.Raycast from the screen to a flat plane on the sphere and use the CrossProduct (I think thats the right one, Jesse would probably know that though) to get the axis for rotation.

I’ve re-read the thread a couple of times, and it’s still not clear to me that that’s what he’s asking. Perhaps it’s more clear to you though.

The description is an exact duplication of a game called Marble Madness

Hehe, I know you keep saying it’s clear what the OP is asking :slight_smile: And maybe it is. But for whatever reason, it’s not clear to me.

Take this quote for instance:

I read this as, “In the game I’m working on, the ball can only ever move in one direction”.

If my interpretation is correct, then what the OP is describing is not the same as Marble Madness. And if my interpretation isn’t correct, my question would be, what should the above statement be taken to mean?

Anyway, it’s not really important; if you understand what the OP is asking and can provide the answers he’s looking for, then that’s all that really matters :slight_smile:

Ok so basically its like teh game “run” in the sense that your are allwasy moving forward, only able to controll left and right, when I get home I’ll make a small web based version. but really I don’t care to much about this project, its just something I found on my hard drive.

Assuming the OP is referring to this game, then I would say it’s not an exact duplicate of Marble Madness. Would you agree?

@The OP: Unless there are complications I’m not thinking of, it shouldn’t be a problem to decouple the direction of rotation from the direction of movement. Anyway, if you decide to pursue this further, perhaps you could post the movement code for the ball for us to take a look at.

yes this is the type of movement I have, the setting is only different, unfortunately I had no time last night to make a web version, i’ll try to do it this weekend.