Movable plants?

Discussions about Coding and Scripting

Movable plants?

Postby JackGriffin » Tue Jan 22, 2019 1:26 am

I've been trying to figure out a way to cause plants to wiggle a bit as you pass (touch) them. I don't want to make animated plants, I'd like to use the stock meshes. Has anyone seen something like this? I know Rune had some but I want to keep my coop server maps the way the map maker intended, I just want the decoration classes to have more interaction. I added falling leaves to the tall trees and they can be burned down if you blast them. I'd like the short plants to move some if they are blasted or if you walk among them.

Thanks if you have any suggestions.
So long, and thanks for all the fish
JackGriffin
Godlike
 
Posts: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Movable plants?

Postby PrinceOfFunky » Tue Jan 22, 2019 2:15 am

JackGriffin wrote:I've been trying to figure out a way to cause plants to wiggle a bit as you pass (touch) them. I don't want to make animated plants, I'd like to use the stock meshes. Has anyone seen something like this? I know Rune had some but I want to keep my coop server maps the way the map maker intended, I just want the decoration classes to have more interaction. I added falling leaves to the tall trees and they can be burned down if you blast them. I'd like the short plants to move some if they are blasted or if you walk among them.

Thanks if you have any suggestions.

If you can subclass the plants you can give them a collision, set the bCollidePlayers to true and write what happens when a player touches them in Touch(), for every player(using the TouchingActors) make them aim a bit away from each, find a middle point where to aim at. In UnTouch() you can do the check, if there are no players touching them then set the rotation to the initial one.
Image
User avatar
PrinceOfFunky
Godlike
 
Posts: 1040
Joined: Mon Aug 31, 2015 10:31 pm

Re: Movable plants?

Postby JackGriffin » Tue Jan 22, 2019 4:34 am

This is actually a pretty good idea. I tried a version of this where I altered the rotation, yaw, pitch, etc a bit in tick (and then in timer) to see if I could get a decent enough effect. None of it looked good at all. It just appeared that the plant was doing things it shouldn't. This just may not be a possibility or I'd have seen something already in a past mod.
So long, and thanks for all the fish
JackGriffin
Godlike
 
Posts: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Movable plants?

Postby PrinceOfFunky » Tue Jan 22, 2019 2:02 pm

JackGriffin wrote:This is actually a pretty good idea. I tried a version of this where I altered the rotation, yaw, pitch, etc a bit in tick (and then in timer) to see if I could get a decent enough effect. None of it looked good at all. It just appeared that the plant was doing things it shouldn't. This just may not be a possibility or I'd have seen something already in a past mod.

Also, I forgot that we cannot choose a pivot point in UT differently from Unreal, so the only way to rotate the plant from the bottom is to attach it to another actor which should be placed at the bottom of the plant and rotate that actor instead.
Image
User avatar
PrinceOfFunky
Godlike
 
Posts: 1040
Joined: Mon Aug 31, 2015 10:31 pm

Re: Movable plants?

Postby JackGriffin » Tue Jan 22, 2019 3:12 pm

I think I'm just going to have to learn simple animation for this and do it that way. I don't see a solution otherwise that works.
So long, and thanks for all the fish
JackGriffin
Godlike
 
Posts: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Movable plants?

Postby Feralidragon » Tue Jan 22, 2019 9:34 pm

This sort of thing already crossed my mind, but to be affected by splash damage weapons and not much for walking through though.
Things like trees bending at the detonation of a nuke for example, stuff like that (I even experimented a bit with it in the far past, when I was still the noobest of noobs at this stuff).

Either way, here's what I think: doing it as an animation is the best and most realistic way to go in this engine.

If you do that, an idea I personally had was to animate it from at least 9 different spots (9 animation sequences): as if the plant was being touched from each one of 8 sides (2 axis plus the diagonals), and one in the middle (where it gets more squashed).
From there, in theory, you could set an animation sequence on touch, and have the plant to transition to another seamlessly, all depending on your position relative to the plant, making the whole effect extremely accurate and good looking.

But in this approach, I am not 100% sure if you can actually do this: for many things I did in the past I had mesh overlays which would match the AnimSequence and AnimFrame of the original actor, and even if the actor was tweening between animation sequences instead of animating a specific sequence from start to finish (which a player actor does a lot for example), I imagine that tweaking the AnimSequence and AnimFrame alone are enough to somewhat make a tween animation between 2 different sequences, but I never really looked into it at all.


The other more simplistic approach, without any animation at all, it's a bit like PrinceOfFunky mentioned, but rotating the plants themselves, and do so every tick while they're being touched, since their rotation must be recalculated no matter how little you move so it matches what you expect to see in the end (a rotation where the plant kinda "looks away" from you), but it should only be a slight otherwise it will look very wrong.
In addition to this, you can perhaps try to toy with other properties, such as Fatness, by decreasing it to make the plant look slightly slimmer while it rotates, and even LODBias, by also decreasing it to make the plant morph and distort a little bit.

For plants which is mostly green leaves and nothing more, you can also try to spawn more of the same plant with different rotations, and then depending on where you are, only one of them would actually rotate while the other plants would stay the same.
A similar approach to this would be to modify those plants somehow to split them into different singular leaves, and then once placed in a map, you could spawn the leaves and do the same thing.


Just my 2 cents


PrinceOfFunky wrote:
JackGriffin wrote:This is actually a pretty good idea. I tried a version of this where I altered the rotation, yaw, pitch, etc a bit in tick (and then in timer) to see if I could get a decent enough effect. None of it looked good at all. It just appeared that the plant was doing things it shouldn't. This just may not be a possibility or I'd have seen something already in a past mod.

Also, I forgot that we cannot choose a pivot point in UT differently from Unreal, so the only way to rotate the plant from the bottom is to attach it to another actor which should be placed at the bottom of the plant and rotate that actor instead.

You can: UT also has PrePivot, it's just not exposed in UEd unlike in Unreal, but it's there and exposed to UScript, so you can freely change it through defaultproperties or code.

But even if you didn't have it, you wouldn't need to do all that.
If you want to rotate an actor relative to an arbitrary 3D location, all you need to do is to define that location, let's say NewPivot, calculate the vector from it to the actor location ( V = A.Location - NewPivot ), rotate it ( V = V >> SomeRotation ), and in the end set the actor location to where the rotated vector is now pointing at ( A.SetLocation(NewPivot + V) ).

It would be a matter of applying a bit of math, and do what the engine itself would do anyway, but without the actor overhead.
User avatar
Feralidragon
Godlike
 
Posts: 5079
Joined: Wed Feb 27, 2008 6:24 pm
Location: Liandri
Personal rank: Work In Progress

Re: Movable plants?

Postby EvilGrins » Wed Jan 23, 2019 3:06 am

JackGriffin wrote:figure out a way to cause plants to wiggle a bit as you pass (touch) them

*has a flashback of the Triffid movies*
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
User avatar
EvilGrins
Godlike
 
Posts: 6203
Joined: Thu Jun 30, 2011 8:12 pm
Location: Palo Alto, CA
Personal rank: God of Fudge

Re: Movable plants?

Postby JackGriffin » Wed Jan 23, 2019 5:46 am

I think I'm just going to bite the bullet on this and rig the plants with a skeleton. It's about time I learned how anyway. I could probably do some combination of the things you stated and make a semi-convincing effect but in the end it's best to just do it correctly and be done with it.

I've been spending some time in Blender and I'm getting comfortable with the basics so it's not so intimidating to consider this path.
So long, and thanks for all the fish
JackGriffin
Godlike
 
Posts: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 4 guests